Thread Subject: fft in MatLab

Subject: fft in MatLab

From: humpty Kumaratunga

Date: 11 Nov, 2009 01:09:03

Message: 1 of 4

Hi,

I am trying to reconcile the differences between Matlab and fftw. And I would like to know how Matlab *plans* it's signal, i.e., what does it use in "fftw_plan"?


if data is an N-dimensional 1D array that holds amplitudes that make up a wave;

in Matlab, I am using -
Y=fft(data(:,2),NFFT);
where 2^(NFFT) = N

and in fftw, I am using:
  static fftw_plan p = fftw_plan_dft_1d(len, data,out,FTW_REDFT01,FFTW_MEASURE);
  fftw_execute(p);

My numbers are off by a non-constant factor. The shapes are similar to each other, but not entirely offset by a constant factor.

Also, I get N/2 results from my Matlab fft output; but get N results from my fftw output.

I could post the two different histograms if people want to take a look - but I am not sure if I can upload graphics here?

Thanks!

- Sujeewa

Subject: fft in MatLab

From: Greg Heath

Date: 11 Nov, 2009 01:51:18

Message: 2 of 4

On Nov 10, 8:09 pm, "humpty Kumaratunga" <suje...@lps.umontreal.ca>
wrote:
> Hi,
>
> I am trying to reconcile the differences between Matlab and fftw. And I would like to know how Matlab *plans* it's signal, i.e., what does it use in "fftw_plan"?
>
> if data is an N-dimensional 1D array that holds amplitudes that make up a wave;
>
> in Matlab, I am using -
> Y=fft(data(:,2),NFFT);
> where 2^(NFFT) = N

That last statement makes no sense.

Hope this helps.

Greg

Subject: fft in MatLab

From: Steven Lord

Date: 11 Nov, 2009 15:29:21

Message: 3 of 4


"humpty Kumaratunga" <sujeewa@lps.umontreal.ca> wrote in message
news:hdd2rf$4ts$1@fred.mathworks.com...
> Hi,
>
> I am trying to reconcile the differences between Matlab and fftw. And I
> would like to know how Matlab *plans* it's signal, i.e., what does it use
> in "fftw_plan"?

Take a look at the FFTW function.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fftw.html

I'm not certain if there will be a 1-to-1 correlation between what you refer
to as "fftw_plan" and the FFTW wisdoms, but you may still find it useful.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: fft in MatLab

From: Steven G. Johnson

Date: 13 Nov, 2009 06:45:44

Message: 4 of 4

On Nov 10, 8:09 pm, "humpty Kumaratunga" <suje...@lps.umontreal.ca>
wrote:
> if data is an N-dimensional 1D array that holds amplitudes that make up a wave;
>
> in Matlab, I am using -
> Y=fft(data(:,2),NFFT);
> where 2^(NFFT) = N
>
> and in fftw, I am using:
>   static fftw_plan  p = fftw_plan_dft_1d(len, data,out,FFTW_REDFT01,FFTW_MEASURE);
>   fftw_execute(p);

First, by passing NFFT in Matlab you are zero padding the array. In
FFTW, it doesn't look like you are zero-padding. Don't zero-pad in
Matlab if you want to get the same results.

Second, it makes no sense whatsoever to pass FFTW_REDFT01 to
fftw_plan_dft_1d. You should be passing FFTW_FORWARD to match the
Matlab FFT function. Moreover, FFTW_REDFT01 is only valid as an
argument to fftw_plan_r2r, and it corresponds to a type of discrete
cosine transform, which is an entirely different operation than the
discrete Fourier transform the Matlab fft function computes.

Regards,
Steven G. Johnson.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
fftw humpty Kumaratunga 10 Nov, 2009 20:14:04
fftw_plan humpty Kumaratunga 10 Nov, 2009 20:14:04
rssFeed for this Thread

Contact us at files@mathworks.com