How I can plot the magnitude and phase response of the transfer function

 Accepted Answer

Try this:
z = tf('z',-1);
H = tf((0.0534*(1+z^-1)*(1-10166*z^-1 + z^-2))/((1-0.683*z^-1)*(1-1.4461*z^-1+0.7957*z^-2)))
H.Variable = 'z^-1'
bode(H)

5 Comments

Thank you for your help.
I have tried it but got an error see below.
Perhaps z is not defined. since my started my intialising the transfer function domain of the IIR filter - below:
%numerator coefficients
b0 = 0.05634;
b1 = [1 1];
b2 = [1 -1.0166 1];
%denominator coefficients
a1 = [1 -0.683];
a2 = [1 -1.4461 0.7957];
Screenshot 2019-12-26 at 13.02.48.png
As previosuly i hadnt had Control system Toolbox.Just installed and it worked.
Although I am not so sure if we are answering the questions propely. I will attach the whole question here again, as this question is manily focused on Digtal signal Processing etc..
Screenshot 2019-12-26 at 13.50.58.png
I assumed that you have the Control System Toolbox, and you want to use it to produce a Bode plot of your transfer function.
To create a Bode plot from the numerator and denominator coefficients:
z = tf('z',-1);
H = tf((0.0534*(1+z^-1)*(1-10166*z^-1 + z^-2))/((1-0.683*z^-1)*(1-1.4461*z^-1+0.7957*z^-2)))
H.Variable = 'z^-1'
num_zinv = H.Numerator{:}
den_zinv = H.Denominator{:}
figure
freqz(num_zinv, den_zinv, 2^14) % Filter Transfer Function: ‘z^-1’ Convention
%numerator coefficients
b0 = 0.05634;
b1 = [1 1];
b2 = [1 -1.0166 1];
%denominator coefficients
a1 = [1 -0.683];
a2 = [1 -1.4461 0.7957];
num = b0 * conv(b1,b2);
den = conv(a1,a2);
figure
freqz(num, den, 2^14)
Using the ‘z^-1’ representation (provided by the Control System Toolbox conversion):
num_zinv = 1.0e+02 * [0.000534000000000 -5.428110000000000 -5.428110000000000 0.000534000000000];
den_zinv = [1.000000000000000 -2.129100000000000 1.783386300000000 -0.543463100000000];
See the documentation on the freqz function to understand how to get outputs from it. The Signal Processing Toolbox does not (to my knowledge) have the ability to use ‘z^-1’ representation, so I used those provided by the Control System Toolbox.
Thank you so much I think this looks much like it...

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!