How can I calculate the inverse fourier transform in matlab?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi. I have to calculate the inverse fourier transform of the function F in may code and compare with the original function f. The code is
w0=15; %frequencia da fonte
w=linspace(1,150,150); %vetor da frequencia
deltaw=w(2)-w(1);
t=linspace(0,30,150); %vetor do tempo
alpha=0.1; %coeficiente de atenuação de sinal sísmico
for nt=1:length(t)
if t(nt)>=0.0
H(nt)=1.0; %H(t) é a função de Heaviside
end
if t(nt)<0.0
H(nt)=0.0;
end
f(nt)=H(nt)*(exp(1)^(-alpha*t(nt)))*sin((pi/180)*w0*t(nt));
end
for nw=1:length(w)
F(nw)=alpha/(alpha^(2)+(w(nw)+(pi/180)*w0)^(2));
end
A=(i*t'*w);
B=exp(A);
Ftempo=(1/(2*pi))*deltaw*(F*B.');
plot(t,f,t,real(Ftempo))
But the graphic is not good. What I have to do?
1 commentaire
Youssef Khmou
le 11 Mar 2013
i tried to change your code , but i do not understand the lines : "A=i*t'*w);......"
Réponse acceptée
Youssef Khmou
le 11 Mar 2013
Modifié(e) : Youssef Khmou
le 11 Mar 2013
hi Marcia,
Are you trying to compute the inverse Fourier Transform of the Heaviside function and compare it with Heaviside function?
you can try this code in which Fast Fourier Transform is computed using loops not built in fft function :
w0=15; %frequencia da fonte
w=linspace(1,150,150); %vetor da frequencia
deltaw=w(2)-w(1);
t=linspace(-10,30,150); %vetor do tempo
alpha=0.1; %coeficiente de atenuação de sinal sísmico
% HEAVIVISE FUNCTION H, F(H)=z and F^1(z)=ZZ
for nt=1:length(t)
if t(nt)<0.0
H(nt)=0.00; %H(t) é a função de Heaviside
elseif t(nt)==0
H(nt)=0.5;
elseif t(nt)>0.0
H(nt)=1.00;
end
end
figure, plot(t,H,'LineWidth',1.9), axis([-10 30 -1 2]), title(' Heaviside function H(x)'), grid on ,
% Fourier Transform, without using FFT
N=length(H);
nfft=N;
z=zeros(1,nfft);
Sum=0;
for k=1:nfft
for jj=1:N
Sum=Sum+H(jj)*exp(-2*pi*j*(jj-1)*(k-1)/nfft);
end
z(k)=Sum;
Sum=0;% Reset
end
figure, plot(w, abs(z),'LineWidth',1.9), title(' Fourier Transform of F[H(x)]'), grid on
% Inverse FOURIER Transform
ZZ=zeros(1,nfft);
Sum=0;
for k=1:nfft
for jj=1:N
Sum=Sum+z(jj)*exp(2*pi*j*(jj-1)*(k-1)/nfft);
end
ZZ(k)=Sum;
Sum=0;% Reset
end
ZZ=ZZ/N;
figure, plot(t, real(ZZ),'LineWidth',1.9), title(' Inverse Fourier Transform F^{-1}[F[H(x)]]=H(x)'), grid on
axis([-10 30 -1 2])
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!