Single-Sided Amplitude Spectrum Plot
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
