LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building appended 2D array

Hello everyone,

 

I've spent the last few hours thinking about how I want to do this, and could use some help.  I have a case structure nested inside two for loops.  After analyzing some data in the inner for loop, every time the case structure is true, it writes to a 2D array.  Now the problem is when the outer for loop goes to the next iteration, it overwrites the previous 2D array that was written.  I'd like that every time the inner for loop is finished, it appends the data to a 2D array.  Hopefully that makes sense.  Seems like it should be simple, but I can't figure out what I'm doing wrong.

 

Thanks!
Alex

 

 

 

 

0 Kudos
Message 1 of 6
(3,118 Views)
If you wire a 2d array constant from outside the for loops to a shift register you can use the shift register to hold the array.  When you want to append data to the array you can use Build Array, with the first element being the shift register and the new element the one you want to append to the end.  I will have a snippet in a bit.
0 Kudos
Message 2 of 6
(3,112 Views)

Hi Alex,

 

Since you want to keep your array for each iteration, you need a shift register for the outer loop as well. You may want to have another shot. Btw, replacing a initialized array is always more efficient than just appending to the previous array, but you can ignore it for now. Just when your data set grows you need to do some changes. 

 

Regards,

Bo

------------------------
My blog Let's LabVIEW.
0 Kudos
Message 3 of 6
(3,109 Views)

You had the basic idea for your code.  You just needed to expand it slightly to provide a varaible to store all the iteration's data.

Arraybuild.png

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

Aaaaaaaaah!  Concatenate inputs!  Not sure how I forgot to do that.  I tried what you had there, but forgot to select that option.  Thanks alot!

 

Foolooo:  Not sure what you meant by your post.  How do I make this code more efficient?

 

Thanks! 

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

Hi, Alex

 

Sorry to confuse you. I think you solved the problem already. What I meant is initialize an array first, and then replace the subset instead of 'appending to the array'. Thats just a thought, a way to use the memory more efficiently. If your data set is *big*, you may want to concern about it, or else just forget it. Hope this answers your question.

 

Cheers,

Bo 

------------------------
My blog Let's LabVIEW.
0 Kudos
Message 6 of 6
(3,073 Views)