Effacer les filtres
Effacer les filtres

sampling and FFT of a sinusoid signal

1 vue (au cours des 30 derniers jours)
Yian Chen
Yian Chen le 26 Sep 2021
Commenté : Chunru le 27 Sep 2021
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?

Réponse acceptée

Chunru
Chunru le 27 Sep 2021
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 commentaires
Yian Chen
Yian Chen le 27 Sep 2021
Modifié(e) : Yian Chen le 27 Sep 2021
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 le 27 Sep 2021
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by