cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab FFT vs LabVIEW FFT

Highlighted
etedwin
Member

Matlab FFT vs LabVIEW FFT

Message contains an attachment

Hi i am new to LabVIEW, not to mention using FFT algorithm in LabVIEW.

Hence, as i try to convert my matlab codes to labview, i notice there are big differences in my result.

 

I have attached my mathlab codes, and snippets of the result.

 

Greatly appreciate if anybody can help me out. Thanks alot in advance!

15 REPLIES 15
Bob_Schor
Knight of NI

Re: Matlab FFT vs LabVIEW FFT

It would help us out if you could describe, in words, what you see as the difference without requiring us to download and wade through your examples.  Pretend we are your Professors -- I hope you don't go up to them and say "Please down load these questions I have and send me an e-mail with the answers ...".

 

Bob Schor

etedwin
Member

Re: Matlab FFT vs LabVIEW FFT

First and foremost, i have 2 sets of data which i generated from the oscilloscope PXI-5112. Both data are named as raw_ch0_vpd_40ua and raw_ch1_vsupply respectively. While the raw data of the ch0 is the input signal to an external circuit, the raw data of the ch1 is the output.

 

I would like to process both of these signals with FFT in the frequency domain. 

For example in matlab, using the fft syntax of fft(isupply) which isupply is a 1000x4096 matrix of data, the result if a fourier transform of the columns.

As i would like to use LabVIEW to duplicate this result, i have tried using a 2d complex fft vi, which i am not able to get the result as compared to matlab.

 

Please pardon my english. Thanks for any help!

mcduff
Trusted Enthusiast

Re: Matlab FFT vs LabVIEW FFT

Look at the help for both Matlab and LabVIEW. Once difference between the FFTs may be scaling, see how they are defined.

 

In your case Matlab is doing the FFT of the columns, is LabVIEW doing the same, or is it doing the FFT of the rows? You can make a small matrix to test this out in Matlab and LabVIEW.

 

Cheers,

mcduff

etedwin
Member

Re: Matlab FFT vs LabVIEW FFT

Hi mcduff,

 

I think you just englighten me in how fft works for both platform. Another question is how do i perform the fft of the columns in labview, is there any sample which i can refer to? Thanks

IanSh
Member

Re: Matlab FFT vs LabVIEW FFT

Transpose 2D array function switches rows and columns

Ian
LabVIEW since 2012
etedwin
Member

Re: Matlab FFT vs LabVIEW FFT

Hi Ian,

 

I have tried doing 2d array transpose. it does not work

Gregory
Trusted Enthusiast

Re: Matlab FFT vs LabVIEW FFT

Message contains a hyperlink

@etedwin wrote:

 

I would like to process both of these signals with FFT in the frequency domain. 

For example in matlab, using the fft syntax of fft(isupply) which isupply is a 1000x4096 matrix of data, the result if a fourier transform of the columns.

 


That's not true, you can only get the Fourier transform of a continuous function. When you have a discretely sampled signal (not an infinite number of points) you can only perform the discrete (or fast) Fourier transform, which is what FFT stands for. Please look at the LabVIEW help and here is a link to more info on FFTs, what signals they are useful for, other limitations, etc.

 

https://en.wikipedia.org/wiki/Fast_Fourier_transform

etedwin
Member

Re: Matlab FFT vs LabVIEW FFT

Hi is there anybody who can help me extract the 4096 columns from a 1000x4096 matrix which i am still trying. Hence, i can do a fft on the individual column based on my matlab coding.

Bob_Schor
Knight of NI

Re: Matlab FFT vs LabVIEW FFT


@etedwin wrote:

 

I have tried doing 2d array transpose. it does not work


Have you considered looking at the Help for the FFT function?  Do you know the difference between a 1D FFT, a 2D FFT, and a 1D FFT of a 2D array where the columns represent different samples that are not necessarily related and should not be "mixed in" with the computation?

 

Hint #1 -- you want to do a 1D FFT of each column, which is completely different from doing a 2D FFT.

 

Hint #2 -- LabVIEW does 1D FFTs on 1D arrays (of course).  The simplest way to take a 2D array and process it column-wise is to (a) transpose the 2D array, then (b) pass it "through" a single For Loop, taking advantage of the indexing input and output Tunnels to get you one row at a time (what you do with that row is up to you).  You should probably consider doing another transpose on the 2D arrays you'll get out of this For Loop to get the results back in Column order.

 

Bob Schor