フィルターのクリア

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 Center および File ExchangeAntennas, 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