sampling and FFT of a sinusoid signal

7 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by