LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initializing an array to match another array size using the formula node.

Solved!
Go to solution

I would like to input a few different arrays of the same length and constants into the formula node and output an array matching their length after some minor calculations. From another post I found out that I can just initialize the array as such:

 

float pp[100];

 

The problem with this is then I end up with an array much larger than what I need. What I would like to do is something like:

 

float pp[n];

 

where n is either the an input of an array size into the formula node or is something like:

 

n = sizeOfDim(td0,0);    // I'm using a 1-D array here

 

Neither of these methods seem to work. How do I initialize my array "pp" such that it matches the 1-D array length of "td0"?

0 Kudos
Message 1 of 4
(4,088 Views)

Check out this help file, it sounds like it describes what you want to do.

http://zone.ni.com/reference/en-XX/help/371361G-01/lvhowto/arraymanipulationformulan/

Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(4,063 Views)
Solution
Accepted by topic author twolfe13

Probably easiest to do your initialization externally.  Create an input named pp and wire td0 into it as well.  Now create an output with the same name pp and it will contain an array of the desired length.  Of course this assumes you are going to change all elements in pp.  Otherwise, just use intialize array to create a new array and feed in the length of td0, and whatever default value you want (ie. 0 or NaN).  Untouched values will keep this value after the formula node.

Message 3 of 4
(4,042 Views)

Thank you very much. I knew there was probably some magical LabVIEW way to do this. That worked great. Goodbye Formula Express VI. Hello Formula Node.

0 Kudos
Message 4 of 4
(4,028 Views)