Reconstructed Pulse Out of Phase
Mostrar comentarios más antiguos
In my research I'm having a problem reconstructing some pulses, I've replicated the problem I'm having with a simple gaussian pulse. Essentially when I take the IFFT of the pulse, the reconstructed time domain signal is out of phase. I've included my code with the plots, I think the problem is within how I'm reconstructing the time space. Any help is appreciated, thank you!
clear variables
%% FFT Test on Gaussian Pulse
Fs = 100; %Sampling Frequency
t = -0.5:1/Fs:0.5; %Time Vector
L = length(t);
x = 1/(4*sqrt(2*pi*0.01))*(exp(-t.^2/(2*0.01))); %Gaussian pulse
plot(t,x) %plotting pulse
title('Gaussian Pulse')
xlabel('time(t)')
ylabel('Pulse')
n = 2^nextpow2(L);
Y = fft(x,n); %plotting frequency spectrum
P = abs(Y);
f = Fs*(0:(n/2))/n;
plot(f,P(1:n/2+1)
%% Reconstructing Pulse
recon = ifft(Y);
t2 = linspace(-0.5,0.5,128); %Reconstructing Time Space
figure()
plot(t,x)
hold on
plot(t2,recon,'--')
hold off
legend('Original','Reconstruction')
Respuesta aceptada
Más respuestas (1)
I'm not an FFT expert, but it appears to be related to your value of n. At least the shift goes away when I use L instead (seethis example)
%% FFT Test on Gaussian Pulse
Fs = 100; %Sampling Frequency
t = -0.5:1/Fs:0.5; %Time Vector
L = length(t);
x = 1/(4*sqrt(2*pi*0.01))*(exp(-t.^2/(2*0.01))); %Gaussian pulse
plot(t,x) %plotting pulse
title('Gaussian Pulse')
xlabel('time(t)')
ylabel('Pulse')
% n = 2^nextpow2(L);
Y = fft(x); %plotting frequency spectrum
P = abs(Y/L);
f = Fs*(0:(L/2))/L;
plot(f,P(1:L/2+1))
%% Reconstructing Pulse
recon = ifft(Y);
t2 = linspace(-0.5,0.5,L); %Reconstructing Time Space
figure()
plot(t,x)
hold on
plot(t2,recon,'--')
hold off
legend('Original','Reconstruction')
1 comentario
Doug
el 6 de Sept. de 2022
Categorías
Más información sobre Spectral Measurements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







