Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
SYML2nd
SYML2nd le 11 Juil 2019
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)

Réponse acceptée

Star Strider
Star Strider le 11 Juil 2019
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.

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Tags

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by