05-23-2009 11:53 PM - edited 05-23-2009 11:57 PM
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 ?
Solved! Go to Solution.
05-24-2009 07:15 AM - last edited on 10-10-2024 10:20 AM by Content Cleaner
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)?
05-24-2009 07:15 AM - last edited on 10-10-2024 10:21 AM by Content Cleaner
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)?
05-24-2009 07:40 AM - edited 05-24-2009 07:44 AM
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!
05-24-2009 11:26 AM - edited 05-24-2009 11:27 AM
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(....)"
05-24-2009 12:21 PM
05-24-2009 12:22 PM - edited 05-24-2009 12:25 PM
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.
05-24-2009 12:33 PM
05-24-2009 03:18 PM
05-24-2009 03:33 PM
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".