How can i use the ifft() function properly?
Afficher commentaires plus anciens
I have a siganl xt, defined between -2 and 1, so I use fft(xt, 20*length(xt)) to get the signal xt in frecuency, but when i use ifft, i cannot plot again the signal properly, because it is not in the original limits between -2 and 1.
clear
close all
ts=0.01;
fs=1/ts;
t=-10:ts:10;
xt=((t>=-2)&(t<=1)).*((2/(3))*(t+2));
plot(t,xt, 'b','LineWidth',2), grid;
title("\fontsize{15} x(t)"), xlim([-4 4]),
xlabel("\fontsize{15} t"), ylabel("\fontsize{15} x(t)");
xf=fft(xt, 20*length(xt));
xf=fftshift(xf);
f=linspace(-0.5*fs, 0.5*fs,length(xf));
plot(f,abs(xf)/fs,'b','LineWidth',2), grid, title("\fontsize{15} fft(x(t))");
xlim([-3 3]), xlabel("f"), ylabel("| x(f) |"), ylim([0 3])
xt_ifft = fftshift(ifft(ifftshift(xf)));
xt_ifft=abs(xt_ifft);
t1=linspace(-5, 5,length(xt_ifft));
plot(t1, xt_ifft ,'b','LineWidth',2), grid ;
title(" x(t) from ifft ");

from ifft i get

but i need it between -2 and 1
2 commentaires
Julius Muschaweck
le 11 Sep 2021
why do you call fft with (20*length(xt), which will just add a lot of zeros at the end of your xt array?
Andres Diago Matta
le 11 Sep 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


