フィルターのクリア

sampling and FFT of a sinusoid signal

1 回表示 (過去 30 日間)
Yian Chen
Yian Chen 2021 年 9 月 26 日
コメント済み: Chunru 2021 年 9 月 27 日
There is a 50HZ sinusoid signal g(t)=sin(2*pi*50*t) where 0≤t<0.1 and it is sampled at a rate of 250HZ, how can I plot this signal and 25 samples defined from 0-0.1s but does not inlude 0.1s? And how can I get the magnitude spectrum and phase spectrum of this signal?

採用された回答

Chunru
Chunru 2021 年 9 月 27 日
f0 = 50;
fs = 250;
t = (0:1/fs:(0.1-.5/fs)); % [0, 0.1)
g = sin(2*pi*f0*t);
plot(t, g);
L = 512
L = 512
Y = fft(g, L); % compute spectrum, FFT length = 512
f = fs*(0:L-1)/L;
figure
subplot(211); plot(f, abs(Y)), title('Amplitude plot')
subplot(212); plot(f, (angle(Y))), title('Phase plot')
  2 件のコメント
Yian Chen
Yian Chen 2021 年 9 月 27 日
編集済み: Yian Chen 2021 年 9 月 27 日
Thanks for your answer, however, I don't exactly know why t = (0:1/fs:(0.1-.5/fs)) means [0, 0.1) and FFT length = 512, could you please explain them? Thanks!
Chunru
Chunru 2021 年 9 月 27 日
t = (0:1/fs:(0.1-.5/fs)) means the time t starting from 0, with interval of T=1/fs, and eding at half-sample interval before 0.1 sec (to ensure that 01. is not included. Therefore this ensures t in in [0, 0.1).
In order to compute spectrum, you need to do FFT. By default fft(x) will take Fourier Transform with the number of frequency points equat to the data points (in your case it is 25). To have a smoother plot of the spectrum, we can use larger number of NFFT points, there fore we use FFT length = 512 above.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by