LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find FFT of mathematical formula

Hey all,

Is that possible to directly simulate the FFT of a mathematical Formula  in Labview?

For example, how can i simulate the FFT of the following mathematical formula:  v(x,y,t) = ( 1/(4*((pi*t)**(3/2))) ) * exp(-(x**2 + y**2 + z**2)/4t)  ?

thanks

Message 1 of 9
(4,375 Views)

It is not clear exactly what you want to do.

 

You give an expression for v(x,y,t) which contains four variables: x, y, z, and t.

 

You do not specify what Fourier transform you want. Do you want a transform from the time domain to the frequency domain for a particular set of x, y, z or do you want a spatial transform?  If a spatial transform, one, two, or three dimensional?

 

You can calculate FFTs.  What do you mean by simulate?

 

Lynn 

Message 2 of 9
(4,351 Views)

LabVIEW does not do analytical solutions.

 

You can always calculate your function in an suitable grid of x, y, t-values and do a numerical FFT on it.

Is that want you mean by "simulation"?

Message 3 of 9
(4,333 Views)

Sorry for using the word "Simulate".. what i actually meant is to specify the fourier transform from the Time Domain for particular set of x ,y ,z. for this Equation: 

v(x,y,z,t) = ( 1/(4*((pi*t)**(3/2))) ) * exp(-(x**2 + y**2 + z**2)/4t)

is that correct what i have done in the attached file?

Message 4 of 9
(4,295 Views)

I would recommend not to use x,y,z unless you are dealing with a multidimensional problem. From your example, you seems to have a simple 1D problen with "t" as independent valiable, and x,y,z  as simple constants that don't change over the course of the data.

 

Your formula could be simplified by substituting A=x² + y² +z², which is a single constant. Right?

 

I don't understand your code. Why are you taking the fft, throw away the imaginary part, and tranform it again???? 😮 Just take the FFT and be done with it. 🙂

 

Typically, you would also place the controls outside (before) the loop. It is impossible to reliably change controls dunrig the execution of the loop anyway and it would just mess up the data. Polling controls for no good reason over and over is comparatively expensive. Once the controls are before the loop, LabVIEW can treat the values as constants during the loop, significantly streamlining the underlying code. You should calculate x² + y² +z² before the loop. Once is enough!

 

I have the feeling there is much more to this problem. Can you point to a web site that describes the formula?

Message 5 of 9
(4,290 Views)

Why are you taking the Fourier transform twice, once with the FFT.vi and then with the FFT Spectrum.vi?

 

Also, the first  element in the array produced by the for loop has the value Inf, which causes the FFT to produce all Inf.

 

When I replaced the first element with zero then spectra appear.

 

Lynn 

Message 6 of 9
(4,289 Views)
Thanks for the useful hints. Well, now i took the controls x,y,z outside the loop and calculated the fft once, but i have the problem when i run the code i can not see the calculation on the "fft waveform graph".How can i change the code to solve this problem?
Message 7 of 9
(4,261 Views)

well i used the function "delete from array" in order to delete the first element from the array in order to be able to see the fft.

would that be correct?

Message 8 of 9
(4,244 Views)

Correct?  I am not sure.  It will allow you to see a spectrum.  I do not know what significance that first point may have for your system, so I cannot judge whether it is correct.  Since your input signal is a single pulse which decays rapidly, the spectrum does not seem to be very interesting.

 

Also, do not set a loop to run forever and use the abort button to stop the VI.  Put a Stop button on the front panel and wire it to the stop terminal.  In this case it is not much of a problem, but generally an orderly shutdown which closes references, sets I/O to safe default values, saves and closes files, and so on is much better.

 

Lynn

Message 9 of 9
(4,232 Views)