How to plot frequency response, phase response from transfer function

How to plot frequency response, phase response, and pole-zero plot using mathlab

5 Comments

I am looking for plot frequency response, phase response, and pole-zero plot using mathlab
Can you show me the links (from your Google search results) to plot the followng?
  1. frequency response,
  2. phase response, and
  3. pole-zero plot
I will then go through the documentaion and recommend what codes to plot them. Thanks!
https://www.mathworks.com/matlabcentral/answers/498096-how-i-can-plot-the-magnitude-and-phase-response-of-the-transfer-function

Sign in to comment.

Answers (1)

Thanks for link. I used the code and it works. Now, try yours.
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 = 0.0534 z^8 - 542.8 z^7 - 542.8 z^6 + 0.0534 z^5 ----------------------------------------------- z^8 - 2.129 z^7 + 1.783 z^6 - 0.5435 z^5 Sample time: unspecified Discrete-time transfer function.
H.Variable = 'z^-1'
H = 0.0534 - 542.8 z^-1 - 542.8 z^-2 + 0.0534 z^-3 ---------------------------------------------- 1 - 2.129 z^-1 + 1.783 z^-2 - 0.5435 z^-3 Sample time: unspecified Discrete-time transfer function.
num_zinv = H.Numerator{:}
num_zinv = 1×4
0.0534 -542.8110 -542.8110 0.0534
den_zinv = H.Denominator{:}
den_zinv = 1×4
1.0000 -2.1291 1.7834 -0.5435
figure
freqz(num_zinv, den_zinv, 2^14)

11 Comments

>> z = tf('z',-1);
Unrecognized function or variable 'tf'.
got this error
can you justify this
z = tf('z',-1);
H = tf((1+2*z^-1+1*z^-2))/(3.1414+0.585*z^-2)
H.Variable = 'z^-1'
@shahril majid, I'm unsure what you meant by "justify this". is given in the link you provided and I just inserted it into the MATLAB code. Let me know if you are having trouble inserting your own .
yup.. i have trouble insertng to HZ .. can you make it for me
@shahril majid, I don't see any issue in your code. What went wrong? The is the same as yours.
H.Variable = 'z^-1'
H = 1 + 2 z^-1 + z^-2 ------------------ 3.141 + 0.585 z^-2 Sample time: unspecified Discrete-time transfer function.
The Full relevant code is already in the Answer. And I did not change your given Add this line
H.Variable = 'z^-1'
shows the transfer function of your given .
However, your discrete transfer function code in the image (for what reason I don't know why you can't paste the Roman characters of the code directly in this MATLAB forum) lacks the parenthesis. In other words, the brackets () are not properly closed.
It is a very common mistake for programmers/coders who like to type the math equations in the cluttered manner, because they want it fast, but also taking time to troubleshoot the error due to a simple mistake of the math operators and brackets.
First type like this:
H = tf();
then
num = ...; % numerator
den = ...; % denominator
then go back to H
H = tf( ()/() );
and paste the numerator and denominator expressions, for example:
H = tf( (2*z^-1)/(3*z^-2) );
This gurantees that you properly close the brackets.
It's good to hear that it works out. You can actually copy and paste the entire MATLAB code to the Editor and Run (click on the green Play button) the program from there. f you find this mini tutorial is helpful, please consider accepting ✔ and voting 👍 the Answer. You are encouraged to complete the MATLAB Onramp Tutorial for Beginners.
Another option that might be easier to enter if less visually appealing at the command line:
H = tf([1 2 1],[3.1414 0 0.585],-1,'Variable','z^-1')
H = 1 + 2 z^-1 + z^-2 ------------------ 3.141 + 0.585 z^-2 Sample time: unspecified Discrete-time transfer function.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 8 Jul 2022

Commented:

on 9 Jul 2022

Community Treasure Hunt

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

Start Hunting!