LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

insert element by element in a 2D array

Hello!
 
I have a 2D array that I create with the initialize array block. I want to insert in this array element by element. I've used insert into array block but it doen't work because this block only allows to insert whole columns or whole rows but not just an element.
 
What I have to do?
 
Thank you!!
 
Larson
0 Kudos
Message 1 of 6
(4,339 Views)
You can't insert a single element into a 2D array. Every row and every column has to have an equal number of elements. That's the case with LabVIEW and every other programming language. You'll have to create the data for an entire row/column and insert that or put dummy data in the unknown elements (i.e. an empty string or a 0) and do a Replace Array Element when the data is known.
0 Kudos
Message 2 of 6
(4,332 Views)
Are you sure that you do not want to use the 'Replace an array element'?  After all, you have initialized the array, you are not adding onto it best I can tell from your description. Just changing elements.

Paul
0 Kudos
Message 3 of 6
(4,325 Views)
Hello!
I'm trying to do this "vi", but I'm can't. Can you send me an example?
Thanks,
Clécio.
0 Kudos
Message 4 of 6
(4,296 Views)
Which "vi" are you talking about? Do you need an example of insert into array or replace array element?
0 Kudos
Message 5 of 6
(4,290 Views)

See attached vi.  You can replace any element of an initialized 2D array.  Can't replace if array is uninitialized or empty.  But you can insert into an unitialized 2D array, must use 1D array as element to insert.  If you don't wire indeces, new 1D array goes at end of 2D array.

 

- tbob

Inventor of the WORM Global
Message 6 of 6
(4,286 Views)