2
我想要計算矢量XRECW的逆傅里葉變換。出於某種原因,我得到了NAN的矢量。 請幫忙!爲什麼從'trapz'函數出來的矢量是NAN?
t = -2:1/100:2;
x = ((2/5)*sin(5*pi*t))./((1/25)-t.^2);
w = -20*pi:0.01*pi:20*pi;
Hw = (exp(j*pi.*(w./(10*pi)))./(sinc(w./(10*pi)))).*(heaviside(w+5*pi)-heaviside(w-5*pi));%low pass filter
xzohw = 0;
for q=1:20:400
xzohw = xzohw + x(q).*(2./w).*sin(0.1.*w).*exp(-j.*w*0.2*((q-1)/20)+0.5);%calculating fourier transform of xzoh
end
xzohw = abs(xzohw);
xrecw = abs(xzohw.*Hw);%filtering the fourier transform high frequencies
xrect=0;
for q=1:401
xrect(q) = (1/(2*pi)).*trapz(xrecw.*exp(j*w*t(q))); %inverse fourier transform
end
xrect = abs(xrect);
plot(t,xrect)
爲什麼不使用fft()和ifft()函數來計算傅立葉變換? http://www.mathworks.de/help/matlab/ref/fft.html;jsessionid=b512fda0853222a659094479e27f –
您是否試圖找出NaN來自哪裏(通過簡化代碼)? –