I can't make sense of the amplitude spectrum of a signal. Help please.
5 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a sinusoidal signal namely:
signal = sin(2*pi*0.08*t) + sin(2*pi*0.2*t) + sin(2*pi*0.32*t) + sin(2*pi*0.4*t);
so the segment of the code becomes:
freqs = [0.08, 0.2, 0.32, 0.4];
periods = 1./ freqs;
% Let the max value of t be 4 times the largest period
t_max = 4 * periods(1);
% Let us have 500 samples over the interval [0, t_max].
t = linspace(0, t_max, 500);
% The synthesized signal
signal = sin(2*pi*0.08*t) + sin(2*pi*0.2*t) + sin(2*pi*0.32*t) + sin(2*pi*0.4*t);
Now I wanna view the amplitude spectrum for the first 50 samples.
So I did this:
signal_first_50_samples= signal (1:50);
% Display its magnitude spectrum.
N = 64;
signal_spect = abs (fft(signal_first_50_samples,N));
signal_spect = fftshift(signal_spect);
F = [-N/2:N/2-1]/N;
plot (F, signal_spect)
set(gca, 'XTick',[-0.5:0.1:1])
grid on;
I was expecting spikes at each of the frequencies, however, I got this:

can anyone help me understand?
Thanks
0 件のコメント
採用された回答
Image Analyst
2014 年 12 月 7 日
If the signal is 500 samples and has 4 periods, then each period is 125 samples long. If you take less than half that you probably don't have a long enough signal to get a reliable spectrum. You're trying to get a spectrum when some of the frequencies don't even have half a cycle in the signal. Why did you take just 50 and not the whole signal?
4 件のコメント
Image Analyst
2014 年 12 月 7 日
Looks like your sampling frequency is not enough to follow the curves exactly. But at least you're getting all 4 spikes now like you should. It appears that there is some effect of the overall, total sample length because I can see side lobes caused by the sinc function, which is what you will get when you truncate your signal by a rect function. If you had higher resolution and took more cycles, that effect would be less.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!