01-09-2020 02:03 AM
Dear Members,
my code consists of an array with size of 2x8652 in a loop in which each iteration it has new 2x8652 values. I want to create a new array which in the first iteration store all the first 2x8652 values and in second iteration stores again the values next to the previous one so the new array size will be 2x17304 and so on.
can anybody help me how I will do this, which array function I have to use build array or index array or maybe other array functions??
your reply will be highly appreciated.
01-09-2020 02:17 AM
Hi Tasnim,
to build an array you should use the BuildArray function…
Why don't you create a small simple test VI where you try to build an array from two small arrays (like 2×5) in the right order? This way you can easily learn basic array handling in LabVIEW!
01-09-2020 06:22 AM
You may need to use Transpose 2D Array before and after the Build Array to get it to line up the way you want.
01-09-2020 11:04 AM
@crossrulz wrote:
You may need to use Transpose 2D Array before and after the Build Array to get it to line up the way you want.
Here's some background to the point crossrulz is making:
A 2x8652 array means 2 rows, 8652 columns. Total of 17304 elements. These are stored in continguous memory somewhere in 17304 consecutive memory locations. LabVIEW keeps track of how to navigate that memory to treat the values as a 2D array, but they are always *literally* stored in a 1D arrangement.
Next point, let's consider a simpler 2x3 array. Rows 0,1, and Columns 0,1,2. Here is the order that LabVIEW stores them in memory:
R0C0,R0C1,R0C2,R1C0,R1C1,R1C2.
Rows take precedence, so all of Row0 comes first, then all of Row1, etc.
If you think about the nature of this layout, you can start to see why it's not *natural* to append 2D arrays in the manner you'd like. There's no choice but to copy and move around in memory virtually *all* the data that was previously stored.
However, if you originally stored the *transpose* of your 2D array, it'd be 8652 rows x 2 columns. Then it would be much more natural to append another 8652 rows x 2 columns without touching any of the data that was previously stored.
Hence the tip from crossrulz that transposing might be needed.
(Behind the scenes, the LabVIEW compiler is pretty smart with memory management. When it sees that you are appending to an array in a loop, it will probably know to allocate a big memory space in the first place that won't get filled up for many iterations. The transpose approach will let you append naturally for a while before LabVIEW will eventually need to allocate more memory.)
-Kevin P
01-09-2020 01:20 PM
The default when building two arrays together of the same dimension, is to create a new array of dimension + 1. So your two 2D arrays will become a 3D array, with the first index (page) being used to index them.
If you want to build two 2D arrays into a new 2D array, you can right click the "Build Array" function and select "concatenate inputs".
01-14-2020 04:59 AM
What I mean is I have an array with size of 2x8652 inside while loop in which each iteration it updates its values. i want to concatenate its output in each iteration and keep the concatenated output inside the loop.
so my question is how to concatenate the output and keep it inside the loop?
01-14-2020 05:10 AM
Hi Tasnim,
@Tasnim wrote:
so my question is how to concatenate the output and keep it inside the loop?
Use a concatenating output tunnel…
What have you tried? Where did you fail?
01-14-2020 05:22 AM
Hi Gerd,
I used a concatenating output tunnel but my aim not to go out from the loop. i want live concatenating inside the loop.
i will make simple code example and show it to you.
Thank you
01-14-2020 05:42 AM