DC gain discrete-time transfer function error

조회 수: 6 (최근 30일)
Francesco Laezza
Francesco Laezza 2021년 6월 15일
댓글: Francesco Laezza 2021년 6월 16일
Hello everyone,
I'm trying to plot the trasfer function of a CIC filter and I think I'm getting an error in DC gain. The code I'm using is shown here:
M = 8; %Decimation factor
N = 1; %Order of the filter
fs = 25e6; %Sampling frequency
T = 1/fs; %Sampling period
z = tf('z',T);
gain = 1/(M);
num_tf = 1-z^(-M);
den_tf = 1-z^(-1);
tf_tf = (gain*num_tf/den_tf)^N;
figure(1)
plot_tf=bodeplot(tf_tf);
setoptions(plot_tf,'FreqUnits','Hz');
dcgain(tf_tf)
The printed bodeplot is:
that shows a DC gain grather than 1 while the line
dcgain(tf_tf)
gives 1 as result (which should be the right one). What am I doing wrong? Why am I finding thi misbehaviour og bodeplot function?
Thanks in advance

채택된 답변

Paul
Paul 2021년 6월 15일
편집: Paul 2021년 6월 15일
I think the problem is just inaccuracy of the numerical computation of the freuqency response at very small frequencies. Keep in mind that tf_tf, as it's defined, would evaluate to 0/0 at z = exp(j*w) = 1 and that tf_tf as a pole/zero cancellation at z = 1. I don't think (don't know for sure) that bode() tries to deal with pole/zero cancellation. However, i think dcgain does try to deal with that, so it gives the expected answer. The desired, or expected, Bode plot can be obtained by using minreal() on tf_tf to remove the common pole and zero at z = 1
M = 8; %Decimation factor
N = 1; %Order of the filter
fs = 25e6; %Sampling frequency
T = 1/fs; %Sampling period
z = tf('z',T);
gain = 1/(M);
num_tf = 1-z^(-M);
den_tf = 1-z^(-1);
tf_tf = (gain*num_tf/den_tf)^N
tf_tf = 0.125 z^9 - 0.125 z ------------------- z^9 - z^8 Sample time: 4e-08 seconds Discrete-time transfer function.
mrtf_tf = minreal(tf_tf)
mrtf_tf = 0.125 z^7 + 0.125 z^6 + 0.125 z^5 + 0.125 z^4 + 0.125 z^3 + 0.125 z^2 + 0.125 z + 0.125 --------------------------------------------------------------------------------------- z^7 Sample time: 4e-08 seconds Discrete-time transfer function.
bode(tf_tf,mrtf_tf)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by