0% found this document useful (0 votes)
59 views

Control Systems: Lab Instructor: Hussain Asif Lab: 01

This document provides an introduction to using MATLAB for control systems modeling and analysis. It discusses mathematical models like transfer functions and how to represent linear time-invariant systems in MATLAB using tools from the Control System Toolbox. These include specifying models as transfer functions, zero-pole-gain models, or state-space models. It also covers performing operations on different model types and how MATLAB determines the resulting model type.

Uploaded by

Usairum Mirza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Control Systems: Lab Instructor: Hussain Asif Lab: 01

This document provides an introduction to using MATLAB for control systems modeling and analysis. It discusses mathematical models like transfer functions and how to represent linear time-invariant systems in MATLAB using tools from the Control System Toolbox. These include specifying models as transfer functions, zero-pole-gain models, or state-space models. It also covers performing operations on different model types and how MATLAB determines the resulting model type.

Uploaded by

Usairum Mirza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Control Systems

Lab Instructor : Hussain Asif


Lab : 01
Introduction to MATLAB

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

Minimum required software packages


MATLAB and the Control System Toolbox

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

Where p gives coefficients of polynomial 4+ 7𝑥3+14𝑥2+8𝑥

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

1 14 77 212 308 224 64 0 0

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]

and you can calculate the partial fraction expansion as

>> [r, p, k] = residue(b,a)

r=

-1.4167

-0.6653

1.3320

p=

1.5737

-1.1644

-0.4093

k=
-1.2500

Now, convert the partial fraction expansion back to polynomial coefficients.

>> [b,a] = residue(r,p,k)

b=

-1.2500 -0.7500 0.5000 -1.7500

a=

1.0000 -0.0000 -2.0000 -0.7500


LTI MODELS
You can specify LTI systems as:
• Transfer function (TF)
• Zero-pole-gain models (ZPK)
• State-space models (SS)

Creating LTI Models


1. Transfer Function
A SISO transfer function

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,

h = tf([1 0],[1 2 10])

creates the transfer function

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:

h = zpk(0, [1–i 1+i 2], –2)

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’)

Given the SISO transfer function h


= tf([1 1],[1 2 5])
you can extract the numerator and denominator coefficients by typing
>> [num,den] = tfdata(h,'v')
num =
0 1 1

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=tf([1 2],[1 7 10])

sys =
s+2
--------------
s^2 + 7 s + 10

Continuous-time transfer function.

>> 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)

Continuous-time zero/pole/gain model.

Operations on LTI Models Arithmetic


Operations
You can apply almost all arithmetic operations to dynamic system models, including those
shown below.
Operation Description
+ Addition
- Subtraction
* Multiplication
/ Right matrix divide
\ Left matrix divide
inv Inverse
' Pertransposition
.' Transposition
^ Power
Concatenation
System concatenation is done in a matrix-like fashion by
sys = [sys1 , sys2] % horizontal concatenation
sys = [sys1 ; sys2] % vertical concatenation

Precedence Rules That Determine Model Type


This example explains the precedence rules that determine the type of model that results when
you interconnect models of different types. The resulting model is determined by the following
order of precedence:
ss > zpk > tf

You might also like