I would like to know how can I plot amplitude and phase
조회 수: 2 (최근 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)
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!