Borrar filtros
Borrar filtros

strange behavior of plot and freqz

3 visualizaciones (últimos 30 días)
Konstantinos
Konstantinos el 4 de Nov. de 2023
Comentada: Star Strider el 4 de Nov. de 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);

Respuesta aceptada

Star Strider
Star Strider el 4 de Nov. de 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 comentarios
Konstantinos
Konstantinos el 4 de Nov. de 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 el 4 de Nov. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Antennas, Microphones, and Sonar Transducers en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by