필터 지우기
필터 지우기

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 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