Control Systems: Lab Instructor: Hussain Asif Lab: 01
Control Systems: Lab Instructor: Hussain Asif Lab: 01
References
Control Systems Engineering (6th edition) by Norman S. Nise.
Objectives
• To learn to use MATLAB
• Use basic commands of CONTROL SYSTEM TOOLBOX
• Learn about LTI Models
Discussion
Mathematical Models
Mathematical model gives the mathematical relationships relating the output of a system to its
input.
Transfer Function
A mathematical function relating the output or response of a system such as a filter circuit to the
input or stimulus.
System Modeling on MATLAB
The Control System Toolbox offers extensive tools to manipulate and analyze linear time invariant
(LTI) systems. It supports both continuous- and discrete-time systems. In addition, systems can
be single-input/single-output (SISO) or multiple-input/multiple-output (MIMO). But before
moving on with CONTROL SYSTEM TOOLBOX commands, let us revise a few mathematical
commands which are going to be used in this course.
1. poly
Polynomial with specified roots
Syntax
p = poly(r)
where r is a vector returns a row vector whose elements are the coefficients of the polynomial
whose roots are the elements of r.
>> r=[-2 0 -4 -1];
>> p=poly(r)
p=
1 7 14 8 0
2. roots
Polynomial roots
Syntax
r = roots(p)
returns a column vector whose elements are the roots of the polynomial p.
>> r=roots(p) r
=0
-4.0000
-2.0000
-1.0000
3. conv
Convolution and polynomial multiplication
Syntax w =
conv(u,v)
convolves vectors u and v. Algebraically, convolution is the same operation as multiplying the
polynomials whose coefficients are the elements of u and v.
>> p2=conv(p,p) p2
4. residue
Convert between partial fraction expansion and polynomial coefficients
Syntax
[r,p,k] = residue(b,a)
[b,a] = residue(r,p,k)
The residue function converts a quotient of polynomials to pole-residue representation, and back
again. The partial fraction expansion is defined as:
[r,p,k] = residue(b,a) finds the residues, poles, and direct term of a partial fraction expansion of
the ratio of two polynomials.
[b,a] = residue(r,p,k) converts the partial fraction expansion back to the polynomials with
coefficients in b and a.
>>b = [ 5 3 -2 7] >>a =
[-4 0 8 3]
r=
-1.4167
-0.6653
1.3320
p=
1.5737
-1.1644
-0.4093
k=
-1.2500
b=
a=
is characterized by its numerator n(s) and denominator d(s) , both polynomials of the variable s .
h = tf(num,den) creates the SISO transfer function . The variable h is a TF object containing the
numerator and denominator data. For example,
s
s^2 + 2 s + 10
2. Zero-Pole-Gain
SISO zero-pole-gain models are of the form
Where k is a scalar (the gain), and z1,...,zm and p1 ,...,pm are the zeros and poles of the transfer
function . This model is closely related to the transfer function representation: the zeros are
simply the numerator roots, and the poles the denominator roots. The syntax to create such
models is h = zpk(z,p,k) where z and p are the vectors of zeros and poles, and k is the gain. For
example, typing:
produces
Zero/pole/gain:
–2 s
--------------------
(s–2) (s^2 – 2s + 2)
3. State Space
State-space models rely on linear differential or difference equations to describe the
system dynamics. Continuous-time models are of the form
Where x is the state vector and u,y are the input and output vectors. Such models may arise from
the equations of physics, from state-space identification, or by state-space realization of the
system transfer function. Use the command ss to create state-space models:
sys = ss(A,B,C,D)
Data Retrieval
The functions tf, zpk, and ss pack the model data and sample time in a single LTI object. The
following commands perform a convenient one-shot data retrieval any LTI model sys:
[num,den] = tfdata(sys,’v’)
[z,p,k] = zpkdata(sys,’v’)
[a,b,c,d] = ssdata(sys,’v’)
den =
1 2 5
Model Conversion
1. Explicit Conversion
Model conversions are performed by tf, ss, and zpk. Given any LTI model sys, the syntax
is simply
sys = tf(sys) % Conversion to TF
sys = zpk(sys) % Conversion to ZPK
sys = ss(sys) % Conversion to SS
sys =
s+2
--------------
s^2 + 7 s + 10
>> zpk(sys)
ans =
(s+2)
-----------
(s+5) (s+2)
2. Automatic Conversion
Most functions and operations perform automatic conversion to the appropriate model
type. For example, >> sys=tf([1 2],[1 7 10])
sys =
s+2
--------------
s^2 + 7 s + 10
Continuous-time transfer function.
>> [z,p,k] = zpkdata(sys,'v')
z=
-2
p=
-5
-2
k=
1
>> sys2=zpk(z,p,k)
sys2 =
(s+2)
-----------
(s+5) (s+2)