Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
SYML2nd
SYML2nd el 11 de Jul. de 2019
Respondida: Star Strider el 11 de Jul. de 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)

Respuesta aceptada

Star Strider
Star Strider el 11 de Jul. de 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.

Más respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by