LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about array append

Hi,
I have a for loop and an array outside the for loop. In each iteration some values are sent to the array.
For example, after first loop, I send following data to array:
2 3 4 5
4 5 6 7
......
after the second loop, other data send to array again and will overwrite the former data in array. How can I append the data to the array?
I try to use "Insert into array.vi", but how to keep the former array's data?
Thanks.
0 Kudos
Message 1 of 6
(3,097 Views)
In general, you need to use a shift register and "built array". The attached example picture shows how to append a single element to a 1D array.

(You would use a similar method to e.g. append a 1D array to an existing 1D array, add a new row to an existing 2D array, etc. etc. Modify as needed. We can make a more specific example once you tell us a bit more detail about the array dimensions and sizes involved.)
0 Kudos
Message 2 of 6
(3,086 Views)
Also you can use "Insert into array" and keeping the old data using a local variable from the output array to be the input array.
See attatchment.

But please note: Don't use Local variables too much!
-----------------------------
Ayman Mohammad Metwally
Automation Engineer
Egypt - Cairo
0 Kudos
Message 3 of 6
(3,071 Views)
Thank you for your reply. I attached my code, it is a very simple one. I just dont' want the array to be overwritten. How to do that?
Thanks.
Tbird
0 Kudos
Message 4 of 6
(3,070 Views)
Here. just use the insert into array. If you don't wire index values into the function, it appends the data to the array.

___________________
Try to take over the world!
0 Kudos
Message 5 of 6
(3,057 Views)
You have quite a few options.

The attached VI (LabVIEW 7.1) shows two possibilities, either building the table (2D string) or building the array (2D DBL).

(NOTES: If this is in a fast FOR loop it is not useful to update the display inside the loop, simply place the output terminals outside the FOR loop, connected to the shift registers on the right. If you know the final array size and it is relatively big, it is more efficient to initialize the shift register with the full sized array (e.g. filled with zeroes or NaNs), then replace array sections as you go in the loop. This avoids array resizing operations.)
Message 6 of 6
(3,051 Views)