LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

initialize n dimentional array

I want to program a UI that can accept the number of dimensions as input and create an n-dimensional array as output. Anyone can help?

 

0 Kudos
Message 1 of 5
(2,722 Views)

Sorry, I asked my question wrong.

 

The question should be:

If I have an n-dimensional array as input (the number of dimensions n is also an input), is there a way to traverse every element of the array? 

0 Kudos
Message 2 of 5
(2,719 Views)

Yes you can do that, but when the dimension "n" increase the number of index input required to access an element will also increase.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 3 of 5
(2,701 Views)

You can't dynamically set the number of dimensions in an array, if that is what you are asking.  But you can initialize an array of any size.  The Initialize Array can expand, so you can create an N dimensional array that way.  LabVIEW has to know the data type, and the number of dimensions is part of the array data type.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(2,663 Views)

You can internally initialize an array with the maximum number of dimensions, then only fill some of the dimensions. Keep track of the highest "used" dimension.

 

You can easily traverse all used elements. What have you tried?

(easiest would be to reshape to a 1D array, then autoindex at a FOR loop boundary).

0 Kudos
Message 5 of 5
(2,646 Views)