From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build a 2-dim array

Hello!

Now we have this problem: We start with a for-loop that runs as many times as there are numbers of signals. Then we want to create a 2-dim array. We know the numbers of columns but not number of rows... so the numbers of coumns can not be created dynamically like the number of rows. We thought of somethning with the "initialize array" but then one need to know both the numbers of rows and columns... any idea? Thank you and best regards.
0 Kudos
Message 1 of 9
(2,991 Views)
Hello Ex-jobb:

You can use the "Build Array" function, and disable the concatinate inputs. The output is connected to the "Previous Value" input of a "Feedback Node", while the "Next Value" output, is connected to the "Array" input of the "Build Array" function. Make sure that there is an empty two dimensional array connected to the "Initialize" terminal of the "Feedback Node".

The last output of the "Build Array" function is the two dimensional array that you are looking for.

But in this method, the number of rows is the one that is defined. You can just connect a "Transpose 2D Array" function if you want.

I hope this helps. Inform me if you need more clarification.
0 Kudos
Message 2 of 9
(2,985 Views)
Hello!

Thank you very much for your help! We tried to do as you suggested, but we did not solve it... we send an attached VI, is this something like you meant? We wonder how to get our values in the array? Or is this wrong?

Best regards!
0 Kudos
Message 3 of 9
(2,979 Views)
Ex-jobb,

So far, your question does not make a lot of sense. Where exactly is the second dimension coming from, what determines it's size?
Should this happen inside the FOR loop or after the FOR loop has finished?

Please attach a VI with some real sample data. e.g. create a few diagram array constants with possible input data and a diagram constant how the output should look like.
0 Kudos
Message 4 of 9
(2,963 Views)
Hello!

If we try to explain our problem from the beginning? We want to build a 2-dim array. We do not know how many rows there will be in the end. We run a measurement and while we are not pushing button "stop measure" shall the array be filled with values row by row. The numbers of columns we know from a previous step in the program...

Then when we push the button we of course knows how many rows there were. We can not send any datas yet because we do not have any measurement yet... the problem is how to do this principally... does this make any sense? Best regards.
0 Kudos
Message 5 of 9
(2,948 Views)
Hello Ex-jobb:

I saw your attachment. I think you got it correct, although you have to use a "While Loop" instead of a "For Loop". If you want, you can check my attachment for a clearer explanation.

If you have any other questions, please don't hesitate to ask.
0 Kudos
Message 6 of 9
(2,944 Views)
Hello!

Thank you for your help! We have a while-loop and then inside it we have cases... we want it to build the array when some of the cases are true and so on. The problem now is that we do not know how to get our values in the array. We have a "list" with the two values "timestamp" and "data" that we want to get into the array... does this make any sense? Best regards.
0 Kudos
Message 7 of 9
(2,940 Views)
Typically it ie easiest to use a shift register and build the array by adding new rows. (see attached, LV 7.0).
If you had something different in mind, please explain.

(If you expect the arrays to become very large, building arrays this way may cause slowdowns due to memory allocations.)
0 Kudos
Message 8 of 9
(2,929 Views)


@Ex-jobb wrote:
Hello!

The problem now is that we do not know how to get our values in the array.




Hmmm... What values do you want to get? Do you want to get the whole 2-dim array (which I thought the one I did), or just some elements? I assume that your elements are clusters of "timestamp" and "data".
0 Kudos
Message 9 of 9
(2,917 Views)