Azzera filtri
Azzera filtri

sampling and FFT of a sinusoid signal

7 visualizzazioni (ultimi 30 giorni)
Yian Chen
Yian Chen il 26 Set 2021
Commentato: Chunru il 27 Set 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?

Risposta accettata

Chunru
Chunru il 27 Set 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 Commenti
Yian Chen
Yian Chen il 27 Set 2021
Modificato: Yian Chen il 27 Set 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 il 27 Set 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by