Effacer les filtres
Effacer les filtres

strange behavior of plot and freqz

3 vues (au cours des 30 derniers jours)
Konstantinos
Konstantinos le 4 Nov 2023
Commenté : Star Strider le 4 Nov 2023
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);

Réponse acceptée

Star Strider
Star Strider le 4 Nov 2023
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 commentaires
Konstantinos
Konstantinos le 4 Nov 2023
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 le 4 Nov 2023
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Antennas, Microphones, and Sonar Transducers dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by