fft of sin(pi*x/5)./(pi*x) returns NaN

10 次查看(过去 30 天)
Hi,
I don't know why, if I do the G=sin(pi*x/5)./(pi*x), it returns NaN, can you help me?
Thanks
x=-100:0.1:100
G=sin(pi*x/5)./(pi*x)
H= abs(fft(G))
Tinc=0.01
Fs=1/Tinc;
freq =transpose( -Fs/2:Fs/length(G):Fs/2-(Fs/length(G)));
figure()
plot(x,G)
figure()
plot(freq,H)

采纳的回答

Star Strider
Star Strider 2019-7-11
When ‘x’ is 0, ‘G’ becomes 0/0, and the IEEE standard defines that as NaN. Any NaN in a vector will propagate through all calculations involving it to result in the entire vector being NaN.
You can get around that by creating a version of L’Hospital’s rule by addint eps to ‘x’:
G=sin(pi*(x+eps)/5)./(pi*(x+eps))
Thar results in the entire vector — and its fft — being defined and not NaN.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by