LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI of the Day (9/9/2009) - Re/Im to Complex

A fun one for 9/9/9.  Re/Im to Complex.  I am using this particular function as an excuse to point out the power of LV's complex arithmetic (and to create some cool pictures).  Even if you live and work in the "real" world, there are plenty of uses for imaginary numbers.  For instance, you recall that a phasor, given by e^(i w t) = cos(wt) + i sin(wt) = Cis(wt) is a compact and effective tool for many trigonometric calculations.  Converting cartesian coordinates to polar is also a snap with complex number functions.

 

This is also a good time to repeat altenbach's tip from the XY graph VIOTD, the XY graph will accept complex numbers directly and plot the imaginary component versus the real component.  Great for polar plots.  I will also make a shameless plea for my imaginary friend whom I am currently missing.  And for the experts among us, am I missing something, or is there no good reason for the inputs to this function (and those similar) to be required.  I am tired of wiring zeros to the Re terminal when I want a pure imaginary number.

 

Now to the fun part.  Many of LV built-in math functions accept complex numbers.  A phasor can be generated by wiring a complex number to the exponential function.  This is easy to visualize, and even easy to achieve with simple trig functions.  Now let's see what would happen when the phase of a phasor is given by a second phasor.  You could either work through all of the sines of cosines, or just plug it in and see what happens.  The following example lets you choose the number of points and two angular frequencies.  What is shown is the result of taking the complex exponential of a complex exponential.  A lot of complexity from some simple (to code) math.  Enjoy.

 

Phasor1.png

 

Groundrules for VIOTD here

Message Edited by Darin.K on 09-09-2009 10:03 AM
Message 1 of 6
(3,379 Views)

Hi Darin,

attached is a version that has a default value set to 0. Maybe you want to copy the help file of the original one for your own usage and place it on your palette....

 

Felix

Message 2 of 6
(3,341 Views)
Well, now we know how all those fancy visual effects in the movies from the 70's were done.
Message 3 of 6
(3,327 Views)

Darin.K wrote:

e^(i w t)


You can even make your own FFT as follows. 😄 Pretty simple code!

 

 

(of course it's slow, so it's just for educational use ;)).

 

 

Message Edited by altenbach on 09-09-2009 03:19 PM
Message 4 of 6
(3,287 Views)

altenbach wrote:

Darin.K wrote:

e^(i w t)


You can even make your own FFT as follows. 😄 Pretty simple code!

 

 

(of course it's slow, so it's just for educational use ;)).

Message Edited by altenbach on 09-09-2009 03:19 PM

That is pretty cool!  In this case, we'll say the first 'F' is for Finite.

Message 5 of 6
(3,282 Views)

Darin.K wrote: That is pretty cool!  In this case, we'll say the first 'F' is for Finite.

I retained the name FFT to show which of the vi.lib VI it mimics. Of course it's only fast compared to paper and pencil. 😄

 

 

(To be fair, the code is not really my own, but slightly modified version of the baseline code for the fft challenge from back in 2003.)

Message 6 of 6
(3,273 Views)