Continuous-time transfer functions

advertisement
MATLAB-Tutorial 2
Class ECES-304
Presented by : Shubham Bhat
% Nise, N.S.
% Control Systems Engineering, 4th ed.
% John Wiley & Sons, Hoboken, NJ, 07030
%
% Control Systems Engineering Toolbox Version 4.0
% Copyright © 2004 by John Wiley & Sons, Inc.
%
% (ch2p8) Example 2.3: Let us do Example 2.3 in the book using MATLAB.
'(ch2p8) Example 2.3'
% Display label.
numy=32;
deny=poly([0 -4 -8]);
[r,p,k] = residue(numy,deny)
% Define numerator.
% Define denominator.
% Calculate residues, poles, and
% direct quotient.
Creating and handling LTI-models (Linear Time-Invariant)
The models supported by CST are continuous-time models and
discrete-time models of the following types:
•transfer functions
•state-space models
Creating models
We will start with continuous-time models, and then take discrete-time models.
•Continuous-time transfer functions
The function "tf" creates transfer functions.
"tf" needs two MATLAB-vectors, one containing the coefficients of the
numerator polynomial - taken in descending orders - and one for the
denominator polynomial of the transfer function.
As an example we will create the transfer function
H0(s)=K0*s/(T0*s+1)
K0=2; T0=4;
num0=[K0,0]; den0=[T0,1];
H0=tf(num0,den0);
% Nise, N.S.
% Control Systems Engineering, 4th ed.
% John Wiley & Sons, Hoboken, NJ, 07030
%
% Control Systems Engineering Toolbox Version 4.0
% Copyright © 2004 by John Wiley & Sons, Inc.
%
% (ch2p9): Creating Transfer Functions
% (1) Vector Method, Polynomial Form:
% A transfer function can be expressed as a numerator polynomial divided by a
% denominator polynomial, i.e. F(s) = N(s)/D(s).
'(ch2p9)'
'Vector Method, Polynomial Form'
numf=150*[1 2 7]
denf=[1 5 4 0]
'F(s)'
F=tf(numf,denf)
clear
% Display label.
% Display label.
% Store 150(s^2+2s+7) in numf and
% display.
% Store s(s+1)(s+4) in denf and
% display.
% Display label.
% Form F(s) and display.
% Clear previous variables from workspace.
'Vector Method, Factored Form'
% Display label.
numg=[-2 -4]
% Store (s+2)(s+4) in numg and
% display.
% Store (s+7)(s+8)(s+9) in deng and
% display.
% Define K.
% Display label.
% Form G(s) and display.
% Clear previous variables from
% workspace.
deng=[-7 -8 -9]
K=20
'G(s)'
G=zpk(numg,deng,K)
clear
Continuous-time state-space models
The function "ss" creates linear state-space models having the form
dx/dt=Ax + Bu ; y=Cx + Du
As illustrated in the following example: Given the following state-space model:
dx1/dt=x2 ;
dx2/dt=-4*x1 -2*x2 + 2*u;
y=x1
This model is created by
A=[0,1;-4,-2]; B=[0;2]; C=[1,0]; D=[0];
ss1=ss(A,B,C,D);
To retrieve the system parameters and give them specific names, we
can execute
[A1,B1,C1,D1,Ts]=ssdata(ss1)
% Nise, N.S.
% Control Systems Engineering, 4th ed.
% John Wiley & Sons, Hoboken, NJ, 07030
%
% Control Systems Engineering Toolbox Version 4.0
% Copyright © 2004 by John Wiley & Sons, Inc.
%
% (ch3p3): The state-space representation consists of specifying the A, B, C, and
% D matrices followed by the creation of an LTI state-space object using the
MATLAB
% command, ss(A,B,C,D). Hence, for the matrices in (ch3p1) and (ch3p2), the
% state-space representation would be:
'(ch3p3)'
A=[0 1 0;0 0 1;-9 -8 -7];
B=[7;8;9];
C=[2 3 4];
D=0;
F=ss(A,B,C,D)
% Display label.
% Represent A.
% Represent column vector B.
% Represent row vector C.
% Represent D.
% Create an LTI object and display.
Homework Problems
% 13. Find the ratio of factors and ratio of polynomials
‘Polynomial form’
Gtf=tf([1 25 20 15 42],[1 13 9 37 35 50])
‘Factored Form’
Gzpk=zpk(Gtf)
% 14. Generate partial fractions
numg=[-10 -60];
deng=[0 -40 -50 (roots([1 7 100]))’ (roots([1 6 90]))’];
[numg,deng]=zp2tf(numg’,deng’,1e4);
Gtf=tf(numg,deng);
G=zpk(Gtf);
[r,p,k]=residue(numg,deng);
Homework Problems
% 10. Write the transfer function in phase variable form
‘a’
Num=100;
Den=[1 20 10 7 100];
G=tf(num,den)
[Acc,Bcc,Ccc,Dcc]=tf2ss(num,den);
Af=flipud(Acc);
A=fliplr(Af)
B=flipud(Bcc)
C=fliplr(Ccc)
Download