フィルターのクリア

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

1 回表示 (過去 30 日間)
mary keshtkar
mary keshtkar 2022 年 10 月 25 日
回答済み: Star Strider 2022 年 10 月 25 日
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 Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by