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

Lab # 05

This lab manual document discusses modeling and simulating linear time-invariant (LTI) systems in MATLAB. It describes how to represent LTI systems using transfer functions, create LTI models in MATLAB, plot pole-zero maps, and simulate responses to inputs like impulses, steps, and arbitrary signals. The objectives are to learn how to model LTI systems and analyze their behavior using MATLAB commands.

Uploaded by

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

Lab # 05

This lab manual document discusses modeling and simulating linear time-invariant (LTI) systems in MATLAB. It describes how to represent LTI systems using transfer functions, create LTI models in MATLAB, plot pole-zero maps, and simulate responses to inputs like impulses, steps, and arbitrary signals. The objectives are to learn how to model LTI systems and analyze their behavior using MATLAB commands.

Uploaded by

ameer hamza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Lab Experiment # 05
Implementation of Linear Time-Invariant Systems in MATLAB
Mass‐Spring System Model
Transfer Function
Linear Time‐Invariant Systems
Examples of Creating LTI Models
Simulation of Linear systems to different inputs
Objective:
This experiment has following two objectives:

 Continued with the learning of Mathematical Modeling from previous experiment, we


now start focusing the linear systems. We will learn commands in MATLAB that
would be used to represent such systems in terms of transfer function or pole-zero-
gain representations.
 We will also learn how to make preliminary analysis of such systems using plots of
poles and zeros locations as well as time response due to impulse, step and arbitrary
inputs.

Apparatus/Software:
Following equipment/software is required:
 MATLAB
Theory:
 Mass-Spring System Model:

The spring force is assumed to be either linear or can be approximated by a linear


function
Fs(x)= Kx, B is the friction coefficient, x(t) is the displacement and Fa(t) is the applied force:

Fig. 3.1

The differential equation for the above Mass-Spring system can be derived as follows
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Transfer Function:
Applying the Laplace transformation while assuming the initial conditions are zeros,
we get

Then the transfer function representation of the system is given by

Linear Time-Invariant Systems In Matlab:


Control System Toolbox in MATLAB offers extensive tools to manipulate and
analyze linear Time-invariant (LTI) models. It supports both continuous- and discrete-time
systems. Systems can be single-input/single-output (SISO) or multiple-input/multiple-output
(MIMO). You can specify LTI models as:
Transfer functions (TF), for example,

Note: All LTI models are represented as a ratio of polynomial functions.

Examples Of Creating Lti Models:


Building LTI models with Control System Toolbox is straightforward. The following
sections show simple examples. Note that all LTI models, i.e. TF, ZPK and SS are also
MATLAB objects.

Example Of Creating Transfer Function Models:


You can create transfer function (TF) models by specifying numerator and
denominator coefficients. For example,

num=[1 0];
den=[1 2 1];
sys=tf(num,den)

sys =

s
-------------
s^2 + 2 s + 1

Continuous-time transfer function.


s=tf('s');
sys=s/(s^2+2*s+1)

sys =
s
-------------
s^2 + 2 s + 1
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Continuous-time transfer function.


This is identical to the previous transfer function.

Example Of Creating Zero-Pole-Gain Models:


To create zero-pole-gain (ZPK) models, you must specify each of the three
components in vector format. For example,
sys=zpk([0],[-1 -1],[1])
sys =

s
-------
(s+1)^2
Continuous-time zero/pole/gain model. Produces the same transfer function built in
the TF example, but the representation is now ZPK.

This example shows a more complicated ZPK model.

sys=zpk([1 0],[-1 -3 -0.28],[-0.776])

sys =

-0.776 s (s-1)
--------------------
(s+1) (s+3) (s+0.28)

Continuous-time zero/pole/gain model.

Plotting Poles And Zeros Of A System:

pzmap
Compute pole-zero map of LTI models

pzmap(sys)
pzmap(sys1,sys2,...,sysN)
[p,z] = pzmap(sys)

Description:
pzmap(sys) plots the pole-zero map
of the continuous- or discrete-time LTI
model sys. For SISO systems, pzmap plots
the transfer function poles and zeros. The
poles are plotted as x's and the zeros are
plotted as o's. pzmap(sys1,sys2,...,sysN)
plots the pole-zero map of several LTI
models on a single figure. The LTI models
can have different numbers of inputs and
outputs. When invoked with left-hand
arguments, [p,z] = pzmap(sys) returns the system poles and zeros in the column vectors p and
z. No plot is drawn on the screen. You can use the functions sgrid or zgrid to plot lines of
constant damping ratio and natural frequency in the s- or z- plane.
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Fig. 3.2

Sample:
Plot the poles and zeros of the continuous-time system.

Matlab Code:

H=tf([2 5 1],[1 2 3]);sgrid

pzmap(H)

Output:
Pole-Zero Map
1.5

1
Imaginary Axis (seconds-1)

0.5

-0.5

-1

-1.5
-2.5 -2 -1.5 -1 -0.5 0
Real Axis (seconds -1)

Fig. 3.3
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Simulation Of Linear Systems To Different Inputs Impulse, Step And Lsim:


You can simulate the LTI systems to inputs like impulse, step and other standard
inputs and see the plot of the response in the figure

Fig. 3.4
window. MATLAB command ‘impulse’ calculates the unit impulse response of the system,
‘step’ calculates the unit step response of the system and ‘lsim’ simulates the (time) response
of continuous or discrete linear systems to arbitrary inputs. When invoked without left-hand
arguments, all three commands plots the response on the screen. For example:
To obtain an impulse response
>> H=tf([2 5 1],[1 2 3]);
>> impulse(H)

Impulse Response
1

0.5

0
Amplitude

-0.5

-1

-1.5

-2
0 1 2 3 4 5 6
Time (seconds)
Fig. 3.5
To obtain a step response type
>> H=tf([2 5 1],[1 2 3]);
>> step(H)
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Step Response
2.5

1.5
Amplitude

0.5

0
0 1 2 3 4 5 6 7 8
Time (seconds)
Fig. 3.6

Time-Interval Specification:
To contain the response of the system you can also specify the time interval to
simulate the system to. For example,

>> H=tf([2 5 1],[1 2 3]);


>> t = 0:0.01:10;
impulse(H,t)
Impulse Response
1

0.5

0
Amplitude

-0.5

-1

-1.5

-2
0 1 2 3 4 5 6 7 8 9 10
Time (seconds)
Fig. 3.7
For step response:

>> H=tf([2 5 1],[1 2 3]);


>> t = 0:0.01:10;
>> step(H,t)
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Step Response
2.5

1.5

Amplitude
1

0.5

0
0 1 2 3 4 5 6 7 8 9 10
Time (seconds)

Fig. 3.8
Simulation To Arbitrary Inputs:
To simulates the (time) response of continuous or discrete linear systems to arbitrary
inputs use ‘lsim’. When invoked without left-hand arguments, ‘lsim’ plots the response on
the screen. lsim(sys,u,t) produces a plot of the time response of the LTI model sys to the input
time history ‘t’,’u’. The vector ‘t’ specifies the time samples for the simulation and consists
of regularly spaced time samples. T = 0:dt:Tfinal The matrix u must have as many rows as
time samples (length(t)) and as many columns as system inputs. Each row u(I,specifies the
input value(s) at the time sample t(i). Simulate and plot the response of the system.
First generate the square wave with gensig. Sample every 0.1 second during 10
seconds:
[u,t]=gensig('square',4,10,0.1);
H = tf([2 5 1],[1 2 3])
H=

2 s^2 + 5 s + 1
---------------
s^2 + 2 s + 3
Continuous-time transfer function.
lsim(H,u,t)
Linear Simulation Results
2.5

1.5

0.5
Amplitude

-0.5

-1

-1.5

-2
0 1 2 3 4 5 6 7 8 9 10
Time (seconds)

Fig. 3.9
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Lab Tasks
Q1: Consider the transfer function

Using MATLAB plot the pole zero map of the above system.
Solution:
Matlab Code:
sys=tf([6 0 1],[1 3 3 7])
pzmap(sys)
Output:
sys =

6 s^2 + 1
---------------------
s^3 + 3 s^2 + 3 s + 7

Continuous-time transfer function.

Pole-Zero Map
2

1.5

1
Imaginary Axis (seconds-1)

0.5

-0.5

-1

-1.5

-2
-3 -2.5 -2 -1.5 -1 -0.5 0
Real Axis (seconds -1)

Fig. 3.10
Q2:
a) Obtain the impulse response for the following system:

b) Obtain the step response for the following system:

c) Explain why the results in a and b are same?

Solution:
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

a)
Matlab Code:
sys=tf([1],[1 0.2 1])
impulse(sys)
Output:
sys =
1
---------------
s^2 + 0.2 s + 1

Continuous-time transfer function.

Impulse Response
1

0.8

0.6

0.4

0.2
Amplitude

-0.2

-0.4

-0.6

-0.8
0 10 20 30 40 50 60
Time (seconds)

Fig. 3.11
b)
Matlab Code:
sys=tf([0 1 0],[1 0.2 1])
step(sys)
Output:
sys =
s
---------------
s^2 + 0.2 s + 1
Continuous-time transfer function.
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Step Response
1

0.8

0.6

0.4

0.2
Amplitude

-0.2

-0.4

-0.6

-0.8
0 10 20 30 40 50 60
Time (seconds)

Fig. 3.12
c)
The results in a and b are same because in part a, numerator has no zero but in part b
numerator has zero due to this reason they are same.
Q3: A system has a transfer function

Plot the response of the system when R(s) is a unit impulse and unit step for the
parameter z=3, 6 and 12.
Solution:
For Impulse response:
At z=3
Matlab Code:
z=3;
sys=tf([15/z 15],[1 3 15])
impulse(sys)
Output:
sys =

5 s + 15
--------------
s^2 + 3 s + 15
Continuous-time transfer function.
Linear Control System, Lab Manual, MTE Department, Wah Engineering College
Impulse Response
5

Amplitude
1

-1

-2
0 0.5 1 1.5 2 2.5 3 3.5
Time (seconds)

Fig. 3.13
At z=6
Matlab Code:
z=6;
sys=tf([15/z 15],[1 3 15])
impulse(sys)
Output:
sys =

2.5 s + 15
--------------
s^2 + 3 s + 15

Continuous-time transfer function.


Impulse Response
3

2.5

1.5
Amplitude

0.5

-0.5

-1
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (seconds)
Fig. 3.14
At z=12
Matlab Code:
z=12;
sys=tf([15/z 15],[1 3 15])
impulse(sys)
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

Output:
sys =

1.25 s + 15
--------------
s^2 + 3 s + 15

Continuous-time transfer function.


Impulse Response
3

2.5

1.5
Amplitude

0.5

-0.5

-1
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (seconds)
Fig. 3.15

For Step Response:


At z=3
Matlab Code:
z=3;
sys=tf([15/z 15],[1 3 15])
step(sys)
Output:

sys =

5 s + 15
--------------
s^2 + 3 s + 15

Continuous-time transfer function.


Linear Control System, Lab Manual, MTE Department, Wah Engineering College
Step Response
1.6

1.4

1.2

Amplitude
0.8

0.6

0.4

0.2

0
0 0.5 1 1.5 2 2.5 3 3.5
Time (seconds)
Fig. 3.16
At z=6
Matlab Code:
z=6;
sys=tf([15/z 15],[1 3 15])
step(sys)
Output:
sys =

2.5 s + 15
--------------
s^2 + 3 s + 15

Continuous-time transfer function.


Step Response
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.5 1 1.5 2 2.5 3 3.5
Time (seconds)

Fig. 3.17
At z=12
Matlab Code:
z=12;
sys=tf([15/z 15],[1 3 15])
Linear Control System, Lab Manual, MTE Department, Wah Engineering College

step(sys)
Output:
sys =
1.25 s + 15
--------------
s^2 + 3 s + 15
Continuous-time transfer function.
Step Response
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.5 1 1.5 2 2.5 3 3.5
Time (seconds)

Fig. 3.18
Conclusion:
In this lab we learnt about the Linear Time-Invariant Systems and Representation. We
have also learnt to make preliminary analysis of such systems using plots of poles and zeros
locations as well as time response due to impulse, step and arbitrary inputs.

You might also like