LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

initializing arrays

Hello!
 
I'm doing a program which works with arrays. I use initialize block arrays to create them. But it depends on other variables the dimension of these arrays. If I want to change the length of a dimension I wire a variable to the block, but I have no idea what can I wire to the block to modify the number of dimensions....it cannot be modify when the program is running?? How I have to do modify the number of dimensions depends on a variable?
 
Thank you in advance!
Larson
0 Kudos
Message 1 of 4
(2,915 Views)

Why do you need to modify the number of dimensions? If you explain your problem, we can probably help you solve it.

If you really do need more than one option, you will have to create a case structure or different subVIs, where each frame or VI handle one type of array, because the number of dimensions is embedded in the wire - a wire can be ONLY 2D or ONLY 1D and so on.


___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(2,902 Views)

You must carry the array at the highest dimension you possibly need (e.g. 3D). Nothing prevents you from using it as a pseudo 1D or pseudo 2D array by setting certain dimensions to lenght=1.

For example: To use it as a 1D array of lenght 50, initialize it as a 3D arrray of 50x1x1. 😉

Message 3 of 4
(2,889 Views)
The initialize array function is a growable function, that is it changes the function inputs by dragging the dimensions not programatically.  There is a work around, you can use a case structure to call different versions of the function.  This will work but will only for a finite number of cases.  The other way is to initialize a multidimensional array as a single dimension and then pass it to the resize array function, i.e initialize ARRAY[i*j*k] and resize to ARRAY[i][j][k].  This is a little unusual to deal with arrays which change at runtime.  The final approach it to write polymorphic functions to handle the different cases, again you will not have full dynamic run-time handling of all possible cases but can handle a few cases easily.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 4
(2,886 Views)