05-16-2012 11:54 AM
I have an array e.g [0, 2, 4, 6, 8]. I want to pass this array to a formula node which calculate the square of each of the element of the input array, and show the resultant array.
For example, the formula is "square". So output array should be [0, 4, 16, 36, 64]
I did like this but there was an error..
Can someone please help?
Solved! Go to Solution.
05-16-2012 11:55 AM
05-16-2012 12:23 PM - edited 05-16-2012 12:24 PM
Why not just use the X^2 function on the numeric palette?
The problem with your formula node is that you don't have the Y output defined as an array. Also, I don't think you can do math on arrays like that in a formula node. You'd have to put in a For Loop and go through it element by element.

05-16-2012 12:32 PM - edited 05-16-2012 12:35 PM
If there is only 1 variable in the equation, I'm a fan of the expression node. But in this case, I'm with Ravens Fan: use the built in primitive.
05-16-2012 12:35 PM - edited 05-16-2012 12:37 PM
Here is how you do it with a formula node.
You tell me which looks easier to code?
It took me 2 seconds using the square function. And 10 minutes to get the syntax right for the formula node.

05-16-2012 05:22 PM
The squaring function is easier, but the formula node looks more impressive.![]()
05-16-2012 06:59 PM
I didn't know you could use arrays in the function node. That'll give me something new to play with.
05-16-2012 09:25 PM
@MoReese wrote:
The squaring function is easier, but the formula node looks more impressive.
Head over to the Rube Goldberg Thread. You'll be amazed! ![]()
11-27-2012 07:58 PM
RavensFan,
Could you explain how you got that? I have a similar situation but the formula it not that simple.
Thanks!
11-27-2012 10:10 PM
I don't know what you are looking for. Are you looking for the equivalent LabVIEW code for what is in the formula node? Or are you looking to turn the variable y into a 2-D array so that your formula is in a loop to convert all the 2-D array X-values to Y-values?