Single-Sided Amplitude Spectrum Plot
Mostrar comentarios más antiguos
Hello,
I have a question regarding the fourier spectrum of a signal. Below I've posted code in which I generated a sinusoidal signal with a frequency of 5 kHz. Then I plotted the single-sided amplitude spectrum as recommended in the MathWorks documentation. The plot however does not show a peak of height 1 at 5 kHz, but a slightly lower one plus more frequencies in the vicinity. What happened there? Since my sampling rate is 20 kHz I dont suppose to violate the Nyquist theorem. Thanks for any hints!
if true
delta = 50E-6;
fs = 1/delta;
time = 0:delta:1;
f = 5E3;
signal = sin(2*pi*f*time);
figure;
plot(time,signal);
x = signal;
y = fft(x);
L = length(x);
P2 = abs(y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
freq = fs*(0:(L/2))/L;
figure;
%loglog(freq,P1);
%semilogy(freq,P1);
plot(freq,P1);
end
1 comentario
twig27
el 28 de Nov. de 2016
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Spectral Measurements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
