Filter löschen
Filter löschen

dbode results in phase shift that is wrong (I believe)

17 Ansichten (letzte 30 Tage)
Brian Tremaine
Brian Tremaine am 21 Jan. 2022
Kommentiert: Brian Tremaine am 21 Jan. 2022
I'm looking at bode plots of linear phase FIR filters and I believe I am getting the wrong phase plot with filter order > 5.
In particular, I'm looking at a moving average filter.
% FIR phase error ?
% LFIR.m
Ts= 1E-3;
n=6;
num= (1/n)*[ones(1,n)];
den= [1 zeros(1,n)];
sys=tf(num,den,Ts);
figure(1); pzmap(sys);
figure(2); dbode(num,den,Ts);
From the pzmap it can be seen that for small positive frequencies on the unit circle the phase contribution should be near zero. However the dbode plot shows the phase at w=0 r/s to be 360 degree. If I use n=5 or less, I do get 0 deg phase at w ~= 0 rad/sec. Is this a problem with dbode?
MATLAB Version: 9.10.0.1739362 (R2021a) Update 5
Here are the pzmap and dbode for n=6:

Akzeptierte Antwort

Paul
Paul am 21 Jan. 2022
dbode() callse bode(), which in turn has an algorithm that tries to "unwrap" the phase by adding multiples of 360 deg across the frequency range. But the phase at each frequency is still correct. We can see this, for example, at low frequency
Ts= 1E-3;
n=6;
num= (1/n)*[ones(1,n)];
den= [1 zeros(1,n)];
sys=tf(num,den,Ts);
[m,p,w] = bode(sys);
p(1)
ans = 357.9946
pcheck = angle(polyval(num,exp(1j*w(1)*Ts))/polyval(den,exp(1j*w(1)*Ts)))*180/pi
pcheck = -2.0054
pcheck + 360
ans = 357.9946
If you prefer the phase to always be between +-180, one approach is to use bodeplot() with phase wrapping on
opts = bodeoptions;
opts.PhaseWrapping = 'on';
bodeplot(sys,opts)
  1 Kommentar
Brian Tremaine
Brian Tremaine am 21 Jan. 2022
Thanks for the very clear and concise answer. Since most my work is on closed loop control systems I'm interested in the unwrapped phase shift below the Nyquist frequency.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by