필터 지우기
필터 지우기

strange behavior of plot and freqz

조회 수: 3 (최근 30일)
Konstantinos
Konstantinos 2023년 11월 4일
댓글: Star Strider 2023년 11월 4일
Hello,
Does anyone knows why the freqz and the plot function display diffrent things?Shouldnt be the same?
For example in the first case everything seems fine but in the second the phase doesnt look the same.
This is my code:
close all;
clear all;
w = -pi:pi/128:pi;
z=tf('z');
G=(0.2*z/(z+0.2))*(1/(z-0.9));
[num,den]=tfdata(G,'v');
figure(1);
freqz(num,den,w);
[h, freq] = freqz(num, den, w);
phase = angle(h);
figure(2);
plot(freq, phase);
clear all;
w = -pi:pi/128:pi;
z=tf('z');
G=(0.2*z/(z+0.2))*(1/(z-0.9))*(1/(z-1));
[num,den]=tfdata(G,'v');
figure(3);
freqz(num,den,w);
[h, freq] = freqz(num, den, w);
phase = angle(h);
figure(4);
plot(freq, phase);

채택된 답변

Star Strider
Star Strider 2023년 11월 4일
Thje angle functon returns angles in radians. If you add a call to the rad2deg function, the results will be in degrees, and the plots should look similar. It might also be necessary to use the unwrap function first.
w = -pi:pi/128:pi;
z=tf('z');
G=(0.2*z/(z+0.2))*(1/(z-0.9));
[num,den]=tfdata(G,'v');
[h, freq] = freqz(num, den, w);
phase = angle(h);
figure(2);
plot(freq, rad2deg(unwrap(phase)))
w = -pi:pi/128:pi;
z=tf('z');
G=(0.2*z/(z+0.2))*(1/(z-0.9))*(1/(z-1));
[num,den]=tfdata(G,'v');
[h, freq] = freqz(num, den, w);
phase = angle(h);
figure(4);
plot(freq, rad2deg(unwrap(phase)))
The aspect ratios are different because freqz produces subplot plots.
.
  댓글 수: 2
Konstantinos
Konstantinos 2023년 11월 4일
I didnt expect that it would change so much the form of the graph.Thanks a lot for the clarification and your solution!
Star Strider
Star Strider 2023년 11월 4일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Antennas, Microphones, and Sonar Transducers에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by