LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding single element of 1D array sequentially to new single array

Solved!
Go to solution

Hi 

 

I am getting a 1D array of double inside the while loop. The 1D array consists of just a single element and it overwrites itself everytime in the loop. I need to store it in a separte array of given length before the overwrite.

 

For example: I am getting 1D array from 1 to 10 but sequentially i.e. 1 then next loop 2 then 3 and so on. 2 overwrites 1, 3 overwrites 2 and so on. What I need to do is save the incoming values before the overwrite from 1 to 10 in a single separate array.

 

I tried to use Index array and Build array functions but I could not get the desired result. I also tried using shift register but I think I am wrong somewhere. Will you please help me. 

 

Thank you for your help. 

 

0 Kudos
Message 1 of 6
(4,042 Views)
Solution
Accepted by topic author Paritosh

Did you want something like this? The array is built up and stored in a shift register (so you were on the right track). Where you might have gone wrong is with the Build Array function - you have to right click and choose 'Concatenate Inputs' in order for it to add each new 1D array to the end of the existing one - if you don't then it adds the new array as another dimension to the existing one!

 

array loop.png

0 Kudos
Message 2 of 6
(4,029 Views)

There are many functions already implemented in LV, use those, less work to do by yourself 😉

 

Example_VI_BD.png

0 Kudos
Message 3 of 6
(4,024 Views)

I just forgot, of course if you want to play with such snippet, put some wait function (Wait (ms)) in it, you do not want to poll your CPU and you wanna see the numbers evolving in the array not too fast.

 

Example_VI_BD.png

0 Kudos
Message 4 of 6
(4,008 Views)

Thank you for your help. Its working now. Thanks for pointing out the concatenation option for the build array function. I was going wrong there. Thanks again Smiley Happy

0 Kudos
Message 5 of 6
(3,957 Views)

Sorry I could not use Data Queue because my input is 1D array but this function accepts only elements from input data point port. Thank you anyways Smiley Tongue 

0 Kudos
Message 6 of 6
(3,951 Views)