I would like to know how can I plot amplitude and phase

1 次查看(过去 30 天)
I would like to know how can I plot amplitude and phase for (x=sin (t)+sin(t).*cos(t) ; for t=[0:0.07:20]
is this correct? or it needs correction?
t=[1:0.07:20];
x=sin(t)+sin(t).*cos(t);
y=fft(x,272);
y1=abs(y);
f=(100/7)/272*(1:272);
plot (f,y1(1:272))
title (‘ Frequency Domain’)
xlabel("f (Hz)")
ylabel("|y1(f)|")
y2=angle(y);
stem (f,y2)

采纳的回答

Star Strider
Star Strider 2022-10-25
I tweaked your code slightly.
Try this —
t=1:0.07:20;
x=sin(t)+sin(t).*cos(t);
Fs = 1/0.07; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(t);
nfft = 2^nextpow2(L); % For Efficiency
y=fft(x,nfft)/L;
y1=abs(y);
f=(0:nfft/2)*Fn*2/nfft;
figure
plot (f,y1(1:numel(f)))
title ('‘Frequency Domain’')
xlabel("f (Hz)")
ylabel("|y1(f)|")
grid
y2=angle(y);
figure
stem (f,y2(1:numel(f)))
grid
It could be interesting to see what the unwrap function does to the phase angle ‘y2’. I leave that experiment to you.
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by