MATLAB Answers

How can I plot the transfer function? HELP Please.

46 views (last 30 days)
hgrlk
hgrlk on 13 Apr 2021 at 10:39
Commented: hgrlk on 14 Apr 2021 at 10:07
Hello, I have a problem with plot the transfer function. I have to plot the precision model's transfer function. To understand my function and precision model, I'll insert a photo.
Here, I must use
numerator = [];
denominator = [];
sys = tf(numerator,denominator)
stepplot(sys)
But I cannot write the numerator and denominator. I have numerator = KH * ( TL*s + 1 ) * exp(-t*s) and denominator = ( TI*s + 1 ) * ( ( (p^2) / (WN^2) ) + ( ( (2*zetaN) / (WN) ) * p ) + (1). As I understand, I must write these numerator and denominator as coefficients of s variable. But I couldn't write. Could you help me please? How can I plot the transfer function?
Also, I want to plot step function with 1 amplitude for compare it with transfer function. How can I do that? Is it just step(sys)?? Is this the same thing with stepplot?
If you could help me, I will be very glad. Thanks!

Accepted Answer

Paul
Paul on 14 Apr 2021 at 1:17
Edited: Paul on 14 Apr 2021 at 1:22
Because you want to make plots, I'm going to assume that you have numerical values for each parameter in your model. For example, suppose we have:
Kh = 2; Tl = 1; Ti = 0.5; wn = 1; zetan = 0.7; tau = 0.2;
At this point, there are several options to form the transfer function F(s). Perhaps the easiest is to start with a product of low order terms:
>> F = Kh*tf([Tl 1],[Ti 1])*tf(1,[1/wn^2 2*zetan/wn 1])
F =
2 s + 2
-----------------------------
0.5 s^3 + 1.7 s^2 + 1.9 s + 1
Continuous-time transfer function.
Now the only part that is missing is the exp(-tau*s). That can be included by either setting the 'InputDelay' or 'OutputDelay' property of F or by mutiplying F by exp(-tau*s) explicilty. For example of the latter:
>> F = F*exp(-tau*tf('s'))
F =
2 s + 2
exp(-0.2*s) * -----------------------------
0.5 s^3 + 1.7 s^2 + 1.9 s + 1
Continuous-time transfer function.
If you'd rather see F expressed in terms of the variable p, you can do:
>> F.Variable='p'
F =
2 p + 2
exp(-0.2*p) * -----------------------------
0.5 p^3 + 1.7 p^2 + 1.9 p + 1
Continuous-time transfer function.
which is just for display purposes and doesn't change any mathematical properties of F. It's not clear what is meant by "plot the ... transfer function." Once F is defined, all sorts of different plots can be developed, most typically:
doc bode
doc step
doc impulse
  1 Comment
hgrlk
hgrlk on 14 Apr 2021 at 10:05
Thank you! :) I totally understand what you did. I think when I'm trying to get numerical values like KH, exp.. etc. in the function directly I got mistake.
The plot part is actually this; I must plot to these transfer function and also I must plot the step function which is amplitude 1. When I'm looking the documentation there is a code which is stepplot(F). But how can I plot the step function? I want it to reach an amplitude of 1 in 1 second.
The reason I do this will be to compare these two graphs.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 13 Apr 2021 at 12:15
You're using both p and s to describe the same p in the formula. Change s to p and I think it should work:
numerator = KH * ( TL*p + 1 ) * exp(-t*p)
term1 = TI*p + 1
term2 = p^2 / WN^2
term3 = 2 * zetaN * p / WN
denominator = term1 * (term2 + term3 + 1)
FH = numerator / denominator
If you'd rather call the independent variable s instead of p, then just change all the p to s.
numerator = KH * ( TL*s + 1 ) * exp(-t*s)
term1 = TI*s + 1
term2 = s^2 / WN^2
term3 = 2 * zetaN * s / WN
denominator = term1 * (term2 + term3 + 1)
FH = numerator / denominator
but don't mix s and p - that could be a disaster if they are separate variables and have different values.
  3 Comments
hgrlk
hgrlk on 14 Apr 2021 at 10:07
Thank you! @Paul solved my problem. :)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!