LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to insert a 1d array line into a 2 d array?

Solved!
Go to solution

I have a vi that acquire the signals of several pulse encoder and store it into a 1d array, and I want to move these data to a 2d array and fill it. I mean I want to acquire signal and store at line 1 of the 2d array, then acquire again and store at line 2 of the 2d array and keep going like this successively.

 

how can I do that?

 

0 Kudos
Message 1 of 5
(4,505 Views)
Solution
Accepted by topic author ManuSpadim

Many ways... same result. The first and the last one are more efficient.

add 1d values to 2d array.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 2 of 5
(4,502 Views)

This and your other question leads me to ask: have you done any of the LabVIEW tutorials? To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. There are also several Technical Resources. You can also take the online courses for free.

0 Kudos
Message 3 of 5
(4,494 Views)

@ManuSpadim wrote:

I have a vi that acquire the signals of several pulse encoder and store it into a 1d array, and I want to move these data to a 2d array and fill it. I mean I want to acquire signal and store at line 1 of the 2d array, then acquire again and store at line 2 of the 2d array and keep going like this successively.



You need to be careful with the terminology, because there are two very different scenarios:

  1. You have an existing 2D array and you want to insert a column(or row), thus growing one of the dimensions by one and moving everything to the right (or bottom) over one slot. (similar to "insert column" in excel)
  2. You have an existing 2D array (possibly all zeroes at the beginning) and you want to replace an existing column with new data. (many newbies call that "insert" too, even though it is not)

If you know the final size of the 2D array, option 2 will be orders of magnitude more efficient, because it avoids constant memory allocations. Every time (almost) you grow an array, it needs to be recreated at a new memory location because arrays need to be contiguous in memory.

0 Kudos
Message 4 of 5
(4,481 Views)

sorry wrong post

0 Kudos
Message 5 of 5
(3,953 Views)