Filter löschen
Filter löschen

sampling and FFT of a sinusoid signal

1 Ansicht (letzte 30 Tage)
Yian Chen
Yian Chen am 26 Sep. 2021
Kommentiert: Chunru am 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?

Akzeptierte Antwort

Chunru
Chunru am 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 Kommentare
Yian Chen
Yian Chen am 27 Sep. 2021
Bearbeitet: Yian Chen am 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 am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by