Uploaded by evan moore

Entering Transfer Functions

advertisement
Using “S” Method
To define a variable “s” to be used in a transfer function later:
>> s=zpk(0,[],1)
s=
s
Continuous-time zero/pole/gain model.
Define a function “G[s]” (you can label it whatever you want, it is not necessary to call it G[s], below is an example from your
notes:
>> Gs =((3*s^2)+(2*s)+1)/(s^2+(4*s)+5)
Gs =
3 (s^2 + 0.6667s + 0.3333)
-------------------------(s^2 + 4s + 5)
Continuous-time zero/pole/gain model.
Using “tf” Method
Use the command “tf” to set the variables of the transfer function, first the numerators, secondly the denominators.
>> Gs =tf([3,2,1],[1,4,5])
Gs =
3 s^2 + 2 s + 1
--------------s^2 + 4 s + 5
Continuous-time transfer function.
Note: It is possible to numerators and denominators before using the “tf” function. Just be aware to include the square brackets
and commas separate the variables when setting the “num” & “den”.
The function would then be called in as >> Gs =tf(num,den)
Using “zpk” Method
If the zeros, poles & gain of a function are already known then the “zpk” method can be used
zeros = [-1, -2]; % Zeros of the transfer function
poles = [-3, -4]; % Poles of the transfer function
gain = 1;
% Gain of the transfer function
sys_zpk = zpk(zeros, poles, gain);d
Gs=sys_zpk
Gs =
(s+1) (s+2)
----------(s+3) (s+4)
Continuous-time zero/pole/gain model.
To add a delay to the function
To add a delay to tsignal use the function below, for a delay on the input type ”inputdelay”, for a delay on the output type
”outputdelay”.
>> numerator = [3, 1];
denominator = [1, 4, 5];
time_delay = 2;
Gs = tf(numerator, denominator, 'OutputDelay', time_delay)
Gs =
3s+1
exp(-2*s) * ------------s^2 + 4 s + 5
Continuous-time transfer function.
If you want to view a plot of the function:
>> step(Gs)
If you want to view a plot of the function:
>> ltiview(Gs)
If you want to view a pole-zero map of the function:
>> ltiview("pzmap",Gs)
If you want to view a Nyquist plot of the function:
>> nyquist(Gs)
If you want to view a Bode plot of the function:
>> bode(Gs)
If you want to view the margins of a function on the Bode plot of the function:
>> margin(Gs)
If given an open loop transfer function you can use the same function as your assignment to view the closed-loop negative unity
feedback system:
>> feedback(Gs,Gs)
ans =
50 (s+10)
-----------------(s^2 + 20s + 2600)
Continuous-time zero/pole/gain model.
If you wish to view both a Nyquist plot and Bode Plot at the same time, then you’ll need to make two graphs. The first graph you
create, no matter what it is, will be labelled “Figure 1” so to create a second you need to call in “Figure 2” and then tell Matlab
what needs to be in that graph. You can do this by using the following
>> figure(2);nyquist(Gs)
Note: In this case it would make the second graph a Nyquist plot, but you can put a Bode or step response in as you please.
Download