difference between FFT(X) and FFT(X,N)
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Wayne King
2012-3-14
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');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!