Showing results for 
Search instead for 
Did you mean: 

Formula Node: Array Size can be specified by wiring an input ?


I have a formula node where I have a module which operates on an array. I want to keep the size of the array generic. So I tried keeping the array size as an input N, and initialized the array as xdim[N]. It shows an error in my formula. what am i doing wrong ?

Kudos are the best way to say thanks 🙂
0 Kudos
Message 1 of 5
As far as I know the formula node syntax doesn't allow a declaration like "float myArray[SIZE]". You have to actually write an integer value and not an identifier. This is described in the documentation. One thing that's not clear from your post is why you need to initialize the array in the formula node. You said you need to operate on an array, so you must be feeding the array into the formula node in the first place. This means you have the array. Are you trying to create a second array?

Corollary: What is it that you're doing that you believe you need a formula node and can't do with pure LabVIEW code?

Message Edited by smercurio_fc on 02-20-2006 10:17 AM

0 Kudos
Message 2 of 5

I had exactly the same issue as Spartan00.


Just for curiosity, I was comparing labview speed in initializing a gaussian array through both the normal graphic code and the formula node.

The formula node proved to be MUCH, MUCH faster.


float m = 0.5, s=0.5, x; int i; float y[1000000]; for(i=0; i<1000000; i++) { x=i*1e-6; y[i]=exp(-pow((x-m),2)/(2*s)); }


Unfortunately, I can't wire the array size as an input.



(By the way, I simply enclosed the formula node in a for loop and let it run 10000 times to get the average execution time. I did the same for the equivalent graphical code and it turned out to be much slower).


Has anybody ever tried to do the same?

0 Kudos
Message 3 of 5

I think your formula node was constant folded. Try passing at least one parameter from LV, e.g. m or s.


0 Kudos
Message 4 of 5

Excellent point dan_u, you are right, thanks.

Now it is sensibly slowed down. Still a bit faster than the G code but the difference is really small now.

0 Kudos
Message 5 of 5