NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
girikavali
Posts: 7
0 Kudos

I want to evaluate a formula which has complex numbers please help me????

I'm a begineer in labview. I want to evaluate an equation which has complex numbers through text code.. Any suggestions Please????

 

for(f=0;f<=2560;f=f+0.3125)

{

     R=((H12-e^(-i*k))/(e^(i*k)-H12))*e^(i*k);

}

 

where H12 is 1d array of complex number

            i         square root of -1

            k         function of frequency

            f          frequency

 

Member
MHoffmann
Posts: 190
0 Kudos

Re: I want to evaluate a formula which has complex numbers please help me????

[ Edited ]

Just use a For-loop in combination with a 1d-array of complex numbers. The following example shows the usage of a array of complex numbers:

 

https://decibel.ni.com/content/docs/DOC-28831

 

Or is there any other problem?

 

Regards,


Michael

Active Participant
MarcoMauri
Posts: 505
0 Kudos

Re: I want to evaluate a formula which has complex numbers please help me????

Hi!

You could try using a script node (http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/scriptnodes/) if you have MATLAB installed on your PC.

 

Or you can implement it in Labview, since there is a Complex data type (actually more than one).

Here's a snippet as a draft/starting point:

 

complex.png

 

Proven Zealot
crossrulz
Posts: 9,384
0 Kudos

Re: I want to evaluate a formula which has complex numbers please help me????

Would you know how to do this if they weren't complex numbers?  If so, then all you have to do is change the numberic representation to a complex data type.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Member
eyeballxxx
Posts: 10
0 Kudos

Re: I want to evaluate a formula which has complex numbers please help me????


girikavali wrote:

I'm a begineer in labview. I want to evaluate an equation which has complex numbers through text code.. 

 


Are you saying you don't want to use LabVIEW to evaluate this? In which case I suggest asking on a different forum.


for(f=0;f<=2560;f=f+0.3125)

{

     R=((H12-e^(-i*k))/(e^(i*k)-H12))*e^(i*k);

}


There is no 'f' in the loop, I don't understand what the loop would evaluate, unless k is a constant in which case the loop is redundant.

 


            k         function of frequency

            f          frequency 


If k is a function of frequency you need to say what that function is. For example if you are evaluating 'k' for changing 'f' and applying it to the equation for R. I don't know what the best procedure would be but my first port of call would be nested loops: 'R' for each 'k' for each 'f' ?

In the absence of a function for k this vi would evaluate you formula for k=f, I don't know if this wil help any.

complexfun.png

Member
girikavali
Posts: 7
0 Kudos

Re: I want to evaluate a formula which has complex numbers please help me????

Thank you Marco Mauri & Michael for your sugesstions..

 

I have implemented it by using loop as you said, but it looks little bit messy, and it becomes difficult to debug,

 

So, script node will be  a better choice. since in my program there are many such equations.

 

I don't have matlab installed in my PC, but i have scilab installed can i use it, If possible i want to know the syntax...

 

Thanks and Regards,

Giridhar

Knight of NI
GerdW
Posts: 10,138
0 Kudos

Re: I want to evaluate a formula which has complex numbers please help me????

Hi girikavali,

 

- when the VI looks messy you should clean it up (there even is the automatic cleanup tool...)

- What means "difficult to debug"? A script node / formula node / scilab node is even more difficult to debug...

 

Best regards,
GerdW


CLAD, using 2009SP1 + LV2011SP1 (sometimes even LV2014) on WinXP+Win7+cRIO
Kudos are welcome :smileywink: