difference between FFT(X) and FFT(X,N)

2 visualizzazioni (ultimi 30 giorni)
zozo
zozo il 14 Mar 2012
Hello,
I have the following:
clc
clear all
close all
Fs=1000;
T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T;
delta_T=2.345 / 1000; %delay time in SECONDS
% Time vector
x = sin(2*pi*50*t);
w=2*pi*50; %angular freq. component
X=fft(x);
Y=X.*exp(1j *2*pi*([0:L/2 -L/2+1:-1])*L*T*delta_T);
y_1=real(ifft(Y));
y_2 = sin(2*pi*50*(t+delta_T));
%plot signals
stem(y_2-y_1); %<--- negligible
If I do the above process efficiently, by performing 'N' point FFT where 'N' is a power of 2, then what changes should be made in the above code to produce same result?

Risposte (1)

Wayne King
Wayne King il 14 Mar 2012
Are you sure you need to use a power of two for efficiency? At any rate you can get rid of the padding in time domain. And although you won't get the perfect reconstruction you are looking for, the waveforms will be very similar.
Fs=1000;
T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T;
delta_T=2.345 / 1000; %delay time in SECONDS
% Time vector
w=2*pi*50; %angular freq. component
x = sin(2*pi*50*t);
Lprime = 2^nextpow2(length(x));
X=fft(x,Lprime);
Y=X.*exp(1j *2*pi*([0:Lprime/2 -Lprime/2+1:-1])*Lprime*T*delta_T);
y_1=real(ifft(Y));
Now if you plot y_1
plot(y_1)
You'll see the effect of the zero padding from point 1000 to 1024. So just throw away the padding
y_1 = y_1(1:L);
However, you will not obtain the kind of perfect reconstruction you were looking for, but compare y_1 and y_2.
y_2 = sin(2*pi*50*(t+delta_T));
plot(y_1)
hold on;
plot(y_2,'k');
  1 Commento
zozo
zozo il 19 Mar 2012
Can someone please explain why this difference is occurring? Is it something to do with wrapping around of circular convolution?

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by