LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert a 1D array into a 2D array while deleting the oldest array?

Solved!
Go to solution

I'm trying to make a 2D array inside a while loop so that when a new 1D array is inserted, it automatically adds it to the end and deletes the oldest data. In this way the array size will remain the same and the 2D array will be continuously updated. I used the insert array function but it keeps adding new 1D arrays to the existing 2D array without deleting the oldest array, resulting in increasing array size. How do you insert a 1D array into 2D array while simultaneously deleting the oldest array?

0 Kudos
Message 1 of 6
(2,683 Views)

Use replace array subset instead. See image below and attached VI, version 2014.

Snip.png

 

 

mcduff

0 Kudos
Message 2 of 6
(2,660 Views)

I assume this will run continuously. It might be much cheaper to replace the oldest row instead of constantly rotating the data with every insertion. What's the overall purpose?

0 Kudos
Message 3 of 6
(2,655 Views)
Solution
Accepted by minmin1004

You need to create a simple flow in your labview code where you delete the first row before or after you add the new data in the last row.

update 2d array.PNG


CLD Using LabVIEW since 2013
0 Kudos
Message 4 of 6
(2,633 Views)

Sounds like you want a circular buffer. This library might have a ready made solution for you:

http://www.ni.com/tutorial/7188/en/

0 Kudos
Message 5 of 6
(2,603 Views)

Thank you! deleting before inserting with array subset function worked!

0 Kudos
Message 6 of 6
(2,591 Views)