LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass array to Eval Formula Node (any chance to avoid this?)

Solved!
Go to solution

 

Hello,

 

 

I haven't MATLAB installed on my PC.

 

I need to be able to input from the Front Panel a custom formula say " y = sin(Fm*2*pi*t[i])+2*sin(3*Fm*2*pi*t[i])+3*sin(4*Fm*2*pi*t[i])....

 

 

 This formula can contain variable count of harmonics (Sine or Cosine functions), but strict number of input parameters: Fm, t[i].

Fm - is a frequency.  

t[i] - is a time (ramp pattern) which is an array 

 

 Can I pass array as an input parameter t[i] into Formula node? How to do this including other parameters, which are constants?

 

 Is there any other method how to implement this - using variable count of functions ?

 

 

 

 

Message Edited by ACiDuser on 05-23-2009 11:57 PM
0 Kudos
Message 1 of 19
(3,315 Views)

I'm a tad confused. Are you referring to the Formula Express VI or the Formula Node? Those are two different beasts. Or, are you referring to using the formula parsing VIs (yet another different beast)?

 

 

Message 2 of 19
(3,290 Views)

I'm a tad confused. Are you referring to the Formula Express VI or the Formula Node? Those are two different beasts. Or, are you referring to using the formula parsing VIs (yet another different beast)?

 

 

0 Kudos
Message 3 of 19
(3,289 Views)

Hi Aciduser,

 

why not use standard math functions of LabView? They can handle arrays very efficiently!

And your formula is crying for using autoindexing FOR loops...

 

Each term of the formula is a*sin(b*Fm*2pi*t[]) . Make an array for a & b, calc Fm*2pi*t[] as "constant term" before the loop, use an autoindexing (a,b) loop, add resulting array to get overall result!

Message Edited by GerdW on 05-24-2009 02:44 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 19
(3,286 Views)

 

I have made this solution... but it works very slow... Is there any other method how to do the same faster?

 

 

 Actually I don't know how to do it with standard LabView functions which can handle arrays, because function count can be variable for example "Sin(....) + 2sin(....) + 3cos(....)" or "sin(...) + cos(....)"

 

Message Edited by ACiDuser on 05-24-2009 11:27 AM
0 Kudos
Message 5 of 19
(3,273 Views)
If I could somehow translate String input - into separate functions and parameters, and count them - I probably could make this thing work without "Eval Formula Node", but I don't know how to translate for example expression " 2*sin(2*pi*Fm*t) + sin(2*pi*Fm*3*t) + 5*cos(2*pi*Fm*3*t) -> translate it so that I know there are 3 functions [sin, sin, cos], and parameters for each function.
0 Kudos
Message 6 of 19
(3,263 Views)
Solution
Accepted by topic author ACiDuser

You are doing this still way too complicated and it is still not scalable for a variable number of terms. You need to be able to get away from text based math and think in terms of real LabVIEW. 😉

 

Here's a quick example using the terms in your first post (I only show an image, because I no longer have LabVIEW 7.1).

 

Modify as needed.

 

 

NOTE:

If you typically have more than a couple of terms, I have the nagging feeling that it would be simpler to setup a complex stick array (with the desired amplitudes and frequency positions) and do a inverse FFT on it.

Message Edited by altenbach on 05-24-2009 10:25 AM
Message 7 of 19
(3,262 Views)
Wow! This looks like exactly what I wanted, Thank you altenbach! Now I'm not sure what is more convenient: using a String input for entering the whole function, or using a Cluster array control as in your solution 🙂
0 Kudos
Message 8 of 19
(3,257 Views)
altenbach, sorry for a trivial question, but how did you make a Scroll-bar for array? 
0 Kudos
Message 9 of 19
(3,241 Views)

I am not sure it if is available in LabVIEW 7.1, but in recent LabVIEW versions you would simply right-click the array and select "Visible items...vertical scrollbar".

 

 

0 Kudos
Message 10 of 19
(3,237 Views)