LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Function node on array

I want to take an array (e.g.  [1,3,5,7,8]) and apply a function to each member, and then return an array afterwords

(e.g.  [exp(1) -2, exp(3) -2, exp(5) -2, exp(7) -2, exp(8) -2)]  )

Could someone please tell me how to do this.  I would very much appreciate it!

Thank you,

inlkjlkj
0 Kudos
Message 1 of 8
(2,957 Views)
Most math functions allow you to wire an array directly in (including the exp function)
Message 2 of 8
(2,948 Views)
Hi JDave,

That is really not working for me....It only wants to output a variable out of the function node, and not an array.  Could I see an example?

Thanks,

inlkjlkj
0 Kudos
Message 3 of 8
(2,943 Views)
Here is some sample code.  If you wire an array in, an array comes out.  Mind that you don't use a for loop, as that will auto index and not maintain the array.
I hope the image clears it up.  I am not sure what you are seeing.  Perhaps you could upload some code or a picture?
Message 4 of 8
(2,939 Views)
I think I see the confusion that we had.  I know that you are able to use the functions on an array itself, but the actual equations were much more complicated that what I wrote down (this is actually going to be converting volts to a temperature), and so I wanted to pass it through a 'function-node' where you can write in several equations (th function node that looks like a case structure) and then output an array. 

Do you know how to do this?  I really appreciate you taking the time to answer...

Thanks,

inlkjlkj
0 Kudos
Message 5 of 8
(2,937 Views)
Using the regular numeric nodes to perform the operations will be faster anyway. Just make the equation into its own sub vi so you don't take up a lot of space. Using a formula node, I think you would have to index each element and perform the calculation like you would in any text based language.
Message 6 of 8
(2,928 Views)
To get an output from the formula node that is not the default float, you need to wire an input with the same name as the output that has the correct type.  Look in the help under formula node.

JDave
0 Kudos
Message 7 of 8
(2,921 Views)

You could also just declare the variable as an array in the formula node.

Message Edited by Marc A on 01-18-2007 01:40 PM

0 Kudos
Message 8 of 8
(2,914 Views)