LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I dynamically assign the dimension of an array in a formula node?

I have an array inside a formula node whose dimension I would like to assign at run time. I tried the following, where s is an input to the formula node:

N = sizeOfDim(s, 0);
float64 myvariable[N];

But got the error message "formula node: index list expected".

If I say

float64 myvariable[1000];

it works fine, unless I happen to need an array that's bigger than 1000!
0 Kudos
Message 1 of 4
(4,480 Views)
Formula nodes cannot dynamically size arrays. This is a nontrivial thing to do in C. I recommend either always using a large array or build a dll for the computations (so you can get the fancy functions) and calling the dll from LabVIEW.

Jeremy
0 Kudos
Message 2 of 4
(4,480 Views)
> I have an array inside a formula node whose dimension I would like to
> assign at run time. I tried the following, where s is an input to the
> formula node:
>
> N = sizeOfDim(s, 0);
> float64 myvariable[N];
>
> But got the error message "formula node: index list expected".
>
> If I say
>
> float64 myvariable[1000];
>
> it works fine, unless I happen to need an array that's bigger than
> 1000!

I'd recommend that you do this using the diagram. Set the array size on
the diagram using the Resize Array node and pass it into the formula.

Greg McKaskle
Message 3 of 4
(4,480 Views)
Of course! Why didn't I think of that? 😉
0 Kudos
Message 4 of 4
(4,480 Views)