1

How can I plot amplitude of transfer function in three dimension (for instance to check poles and zeros on graph) ? Suppose this is my transfer function:

Transfer function

My code:

b = [6 -10 2];
a = [1 -3 2];

[x, y] = meshgrid(-3:0.1:3);
z = x+y*j;

res = (polyval(b, z))./(polyval(a,z));
surf(x,y, abs(res));

Is it correct? I'd also like to know is it possible to mark unit circle on plot?

2 Answers 2

2

I think it's correct. However, you're computing H(z^-1), not H(z). Is that you want to do? For H(z), just reverse the entries in a from left to right (with fliplr), and do the same to b:

res = (polyval(fliplr(b), z))./(polyval(fliplr(a),z));

To plot the unit circle you can use rectangle. Seriously :-) It has a 'Curvature' property which can be set to generate a circle.

It's best if you use imagesc instead of surf to make the circle clearly visible. You will get a view from above, where color represents height (value of abs(H)):

imagesc(-3:0.1:3,-3:0.1:3, abs(res));
hold on
rectangle('curvature', [1 1], 'position', [-1 -1 2 2], 'edgecolor', 'w');
axis equal
Sign up to request clarification or add additional context in comments.

Comments

0

I have never in my whole life heard of a 3D transfer function, it doesn't make sense. I think you are completely wrong: z does not represent a complex number, but the fact that your transfer function is a discrete one, rather than a continuous one (see the Z transform for more details).

The correct way to do this in MATLAB is to use the tf function, which requires the Control System Toolbox (note that I have assumed your discrete sample time to be 0.1s, adjust as required):

>> b = [6 -10 2];
a = [1 -3 2];
>> sys = tf(b,a,0.1,'variable','z^-1')

sys =

  6 - 10 z^-1 + 2 z^-2
  --------------------
  1 - 3 z^-1 + 2 z^-2

Sample time: 0.1 seconds
Discrete-time transfer function.

To plot the transfer function, use the bode or bodeplot function:

bode(sys)

For the poles and zeros, simply use the pole and zero functions.

6 Comments

I don't agree. z does represent a complex number. It makes sense to plot abs(H) as a function of z on the complex plane, for example to identify poles and zeros as the OP says
@LuisMendo When talking about transfer functions and control system design, z always refers to the Z transform in the frequency domain.
But the variable z in the z-transform is actually a complex variable
@LuisMendo True, but you wouldn't normally use the complex representation of the number to plot the transfer function. It seems a very convoluted way.
Unless you want to see the positions of poles and zeros (which don' t normally lie on the unit circle)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.