LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab FFT vs LabVIEW FFT

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!

0 Kudos
Message 1 of 16
(5,225 Views)

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

0 Kudos
Message 2 of 16
(5,212 Views)

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!

0 Kudos
Message 3 of 16
(5,196 Views)

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

0 Kudos
Message 4 of 16
(5,185 Views)

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

0 Kudos
Message 5 of 16
(5,169 Views)

Transpose 2D array function switches rows and columns

Ian
LabVIEW since 2012
0 Kudos
Message 6 of 16
(5,157 Views)

Hi Ian,

 

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

0 Kudos
Message 7 of 16
(5,155 Views)

@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

0 Kudos
Message 8 of 16
(5,146 Views)

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.

0 Kudos
Message 9 of 16
(5,134 Views)

@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

Message 10 of 16
(5,131 Views)

Not sure why transpose does not work.

 

What exactly is Matlab doing? By definition the 2d FFT of a matrix is a FFT in the x(row) direction and a FFT in the y(column) direction. You said Matlab is just doing the FFT on the columns, if that is the case then the following may work.

 

Two Different Methods, your choiceTwo Different Methods, your choice

 mcduff

 

 

 

Message 11 of 16
(1,099 Views)

Hi mcbuff,

 

Thanks for the solution, it is what i am looking for.

0 Kudos
Message 12 of 16
(1,070 Views)

I have a problem, after doing the Fourier transform in labview I get two positive and negative peaks in "y" but they are out and aligned, I did the procedure in matlab and if I get the right peaks aligned, Why do not I do well in labview?

0 Kudos
Message 13 of 16
(967 Views)

Please do not "hijack" an old post.  If you have a new question and a new problem with your code, start a new post, attach your code (please attach VIs, not pictures of parts of your Block Diagram, which are difficult to edit and execute).  Explain what you want to do, what you expect the answer to be, and if data are involved, attach example data.

 

Bob Schor

0 Kudos
Message 14 of 16
(961 Views)

I´m really sorry, but a do not know how to create a new question in this blog.

0 Kudos
Message 15 of 16
(954 Views)

@Gildardo18 wrote:

I´m really sorry, but a do not know how to create a new question in this blog.


Go to the top of this Forum (https://forums.ni.com/t5/LabVIEW/bd-p/170?lang=en).  Scroll down a little until you see the big Blue Button "Start a Topic".  Push it, make an informative Title, and ask your question, posting your code.

 

Bob Schor

0 Kudos
Message 16 of 16
(939 Views)