LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

for loop in formula node

Hi,
 
I wanna do some signal processing after I got the magnitude and phase infos from FFT. But the errors say that there is undefined variables.  I am just wondering that here absP and angleP are both vectors. Can I express them like what I did in the attached vi? 3x.
 
Huihui
 
 
0 Kudos
Message 1 of 11
(4,670 Views)
Your syntax is incorrect as far as the formula node when it comes to accessing array elements. Please check the LabVIEW documentation.

Are you thinking of the Mathscript node instead, which is Matlab-like syntax?
0 Kudos
Message 2 of 11
(4,650 Views)
Thanks for your reply. In fact I do not know the difference between the formula node and Mathscript. Is Mathscript another window interface? I just know we should use C syntax in the formula node but it said that it was wrong even I wrote the program with C at the beginning. Can you tell me how to use Mathscript cause I am familiar with Matlab? Thanks.
 
 
0 Kudos
Message 3 of 11
(4,625 Views)
Hi huihui,

do you just want to know the real and imaginary values of your signal?
Why use formula node at all?
Best regards,
GerdW


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

Hi,

I do not wanna the real and imag parts directly cause I need to do some signal processing firstly and calculate these two parts. Now I am using 8.5. Can u tell me how to use Mathscript in Labview? 3x.

 

0 Kudos
Message 5 of 11
(4,595 Views)
MathScript is essentially NI's version of a Matlab-like system. The Formula Node allows you to enter snippets of code in a C-like syntax. The LabVIEW Help provides details on the syntax of each. There are also examples that ship with LabVIEW. Open the Example Finder (Help -> Find Examples) and then do a search for either "MathScript" or "formula", depending on which one you want to use.
0 Kudos
Message 6 of 11
(4,584 Views)
Hi hxwgter,

I have seen those calculations, but I'm not familiar with this syntax:
AngleP(m+1, k)=angleP(k)-2*pi*m*k/1024
ImagP(m+1,k)=sin(AngleP(m,k).*absP(k))


What is the meaning of 2 indices in array(m,k)? Index an element in a 2d array? Get a vector from the full array?

Labview can calc with arrays, so it will be mostly easier to calc using G instead of several loops in C...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 11
(4,580 Views)
Gerd,

The intention there is to index out a 2D array, but the correct syntax for a formula node is something like a[4][7] to access the element (4,6) of the array "a".
0 Kudos
Message 8 of 11
(4,576 Views)
Thanks smercurio

for explanation.
But then the whole formula node doesn't make a lot of sense as absP() and angleP() are 1d arrays...
And in "AngleP(m+1, k)=angleP(k)-2*pi*m*k/1024" angleP is accessed both as 2d and 1d array???

So there seems to be a bigger problem in those formulas anywaySmiley Tongue
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(4,568 Views)
Hi  GerdW,
 
Thanks for your reply.
 
I changed the index in square bracket. I wanna produce a matrix with m rows and 1024 columuns. The index k here means every signal in every row. I am not clear about using G for calculate the array. Can you tell me something about it ? Thanks.
 
Huihui  
0 Kudos
Message 10 of 11
(4,512 Views)