LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Output type in Formula Node?

I looked at some other posts on how to set a formula node output as an array, and am unsure why it is not an array. Here is the text in my node: ("out", "in1", and "in2" are all supposed to be 2D arrays; i is an int)

int32 out [50][50];
if (i==0)
out = in1;
else
out = in2;
0 Kudos
Message 1 of 3
(3,632 Views)
Hi,
you must use something like

int32 out[50][50];
int32 j, k;
if (i==0)
for (j=0; j<50; j++)
for(k=0; k<50; k++)
out[j][k]=in1[j][k];
else
for (j=0; j<50; j++)
for(k=0; k<50; k++)
out[j][k]=in2[j][k];

I think this is because formula node must be precompiled before execution of your VI. In your case it doesn't know how to address different array elements of "in1" and "in2" because it doesn't know its sizes before you start your VI. In my example I specify the adresses of array elements by using indecies [j][k].

In any case it looks like you can't make direct assignment of arrays like "arr1=arr2". You always must assign its elements in a loop like "arr1[i]=arr2[i]".

Good luck.

Oleg Chutko.
0 Kudos
Message 2 of 3
(3,632 Views)
Oleg is correct. You would be much better off doing this with a case statement or select function if you're not doing anything else in the formula node.
0 Kudos
Message 3 of 3
(3,632 Views)