0% found this document useful (0 votes)
27 views53 pages

Attachment 1

The document provides an introduction to using MATLAB for control systems. It outlines topics including MATLAB basics, advantages and disadvantages, predefined variables, arithmetic operations, and creating and manipulating arrays. The document was written by Esaias Abera of Wollo University in Ethiopia as an introduction for control systems students.

Uploaded by

Yidnekachew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views53 pages

Attachment 1

The document provides an introduction to using MATLAB for control systems. It outlines topics including MATLAB basics, advantages and disadvantages, predefined variables, arithmetic operations, and creating and manipulating arrays. The document was written by Esaias Abera of Wollo University in Ethiopia as an introduction for control systems students.

Uploaded by

Yidnekachew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Introduction to Control System using

MatLab Software

Esaias Abera
esaias.abera@wu.edu.et

Wollo University
Kombolcha Institute of Technology
School of Electrical, Computer and Biomedical Engineering
Kombolcha, Ethiopia

March 19, 2024


Outlines

Outlines

1 Introduction to MatLab

2 Array and Manipulation

3 Graphs and Figures

4 Transfer Function

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 1 / 52
Introduction to MatLab

MatLab Basics

Developed by MathWorks in 1984, USA

High-level language and interactive environment for numerical


computation, visualization, and programming

As of 2020, MatLab has more than 4 million worldwide


users(engineers, scientists, and economists).

More than 5000 colleges and universities around the world use
MatLab and Simulink for teaching and research

MatLab available as application software and web based app at


https://MatLab.mathworks.com/

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 2 / 52
Introduction to MatLab

Advantages of MatLab

Basic data element of MatLab is matrix.

Several mathematical operations that work on arrays or matrices


are built-in to the MatLab environment. For example,
dot-products, array operations.

Vectorized operations: Adding two arrays together needs only


one command, instead of the use of a ’for loop’ or ’while loop’.

One can plot data easily, and then change colors, sizes, scales,
etc of graphical outputs.

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 3 / 52
Introduction to MatLab

Advantages of MatLab

MatLab’s functionality can be greatly expanded by the addition


of toolboxes(signal processing, communications, control, image
processing, and biology, etc.)

One can perform operations from the command line or can create
functions that perform repetitive tasks, just as any other
computer language.

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 4 / 52
Introduction to MatLab

Disadvantages of MatLab

MatLab is an interpreter language(slower than other compiler


languages).

MatLab uses a large amount of memory.

MatLab sits on top of Windows, getting as much CPU time as


Windows allows it to have. This makes real-time applications
complicated.

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 5 / 52
Introduction to MatLab

Applications of MatLab

Matrix computations and linear algebra

Solving nonlinear equations

Solving differential equations

Mathematical optimization

Statistics and data analysis

Signal processing

Modelling of dynamical systems

Solving partial differential equations

Simulation of engineering systems


Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 6 / 52
Introduction to MatLab

MatLab Window

Current folder directory Get help

MATLAB command line prompt

Current folder content Command window Workspace

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 7 / 52
Introduction to MatLab

Basic command

exit or quit % quits MatLab


help topics % shows the lists of topics
who or whos % lists current variables
clear var or clear all % clears variables and functions
from memory(e.g., clear x y)
clc or home % clears the command window and homes
the cursor
pwd or cd % shows current working directory
Any statement after percent sign ’%’ becomes comments

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 8 / 52
Introduction to MatLab

MatLab variables

Variables are used to store information to be referenced and used


by programs

Starts with a letter, followed by letters, digits or underscores ’_’.


Maximum length is 63.

Case sensitive(e.g., Item, ITEM, and item are not same)

Don’t use reserved keywords(break, case, classdef, continue,


else, elseif, end, for, function, global, if, otherwise, parfor,
persistent, return, spmd, switch, try, while)

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 9 / 52
Introduction to MatLab

Example: Defining MatLab variables

» p_value = 10;
» x123 = sqrt(5);
» MyVariable = 1e-5;
» x-point = 70; % wrong, contains minus sign
» 123A = -29; % wrong, start with a number
» if = 5; % wrong, reserved keyword
» var) = 4; % wrong, contains ’)’
» y(z) = 4; % wrong, contains ’()’
» mean value = 21; % wrong, contains blank space

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 10 / 52
Introduction to MatLab

Arithmetic Operations

Operation Symbol
Addition +
Subtraction -
Multiplication *
Right Division /
Left Division \
Power ∧

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 11 / 52
Introduction to MatLab

Predefined variables

pi π = 3.1415926535897....
i or j Imaginary unit = 0 + 1i
eps Epsilon = 2−52 = 2.2204e-16
inf Infinity (∞)
NaN Not-a-Number
realmin Smallest positive floating point number
realmax Largest positive floating point number

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 12 / 52
Introduction to MatLab

Example: predefined varaibles i, j, π, ∞, NaN, eps

» c1=1+2j » y= 2/x
c1= 1.000 + 2.000i y= Inf
» c2 = 6-9*i » q= sin(x)/x
c2= 6.000 - 9.000i q= NaN
» q= real(c2)
q= 6 » x= 0;
»mag= abs(c2) » y= sin(x)/x
mag= 10.8164 y= NaN
» x= eps; % near zero
» a= cos(2*pi) » q= sin(x)/x
a=1 q= 1
» x= 0;

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 13 / 52
Introduction to MatLab

MatLab code executions

1. Use of command window


Commands or statements are entered at command line
prompt ’»’
Line by line execution

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 14 / 52
Introduction to MatLab

MatLab code executions...

2. Use of the editor


Code a sequence of statements
Save it as a script file(M-files)
Execute the file
I Click icon
I Enter file name at prompt
on the command window

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 15 / 52
Array and Manipulation

Creating Array

Basic data structure in »s= 4 % 1x1 array


MatLab is the array. s= 4
»x= [2 5 -2 3] % 1x4 row vector
Even a scalar (number) is x= 2 5 -2 3
considered to be 1x1 matrix. » v= [1;2;3] % 3x1 column vector
v=
1
2
3
x = start:increment:finish % » y= 0:0.5:1.2 % 1x3 row vector
creates an even spaced vector y= 0 0.5000 1.0000
x using increment between » v= 60:-10:15 % 1x5 row vector
start and finish v= 60 50 40 30 20

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 16 / 52
Array and Manipulation

Creating Array...

» w= [2:4]’
w=
2
3
4

x= linspace(x1,x2,N) % generates N points between x1 and x2.

» x= linspace(0,2,5)
x = 0 0.5000 1.0000 1.5000 2.0000

0 0.5 1 1.5 2
Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 17 / 52
Array and Manipulation

Creating Array ...

w= logspace(x,y,N) % generates N points between 10x and 10y

» w= logspace(0,2,5)
w = 1.0000 3.1623 10.0000 31.6228 100.0000

100 100.5 101 101.5 102

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 18 / 52
Array and Manipulation

Example:

Obtain the magnitude of z= 3+jw (10−2 ≤ w ≤ 102 ).

» w= logspace(-2,2,5);
» z= 3+j*w;
» magz= abs(z)
magz = 3.0000 3.0017 3.1623 10.4403 100.0450

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 19 / 52
Array and Manipulation

Example:

Draw the magnitude of s = 9 − jω(10−2 ≤ ω ≤ 102 ).


120

» w= logspace(-2,2,50); 100

» s= 9-j*w; 80

» mag= abs(s); 60

40

» semilogx(w,mag,’linewidth’,2)
20

» grid 0
10-2 10-1 100 101 102

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 20 / 52
Array and Manipulation

Array Manipulation

» x= 0:2:16 % create a vector x


x = 0 2 4 6 8 10 12 14 16
» x(4) % element of x at position
» a= [2 5; -2 3] % 2x2 matrix
4
a=
ans = 6
2 5
» x(1:3) % from position 1 to 3
-2 3
ans = 0 2 4
» b= [1 2 3 0;4 5 6 2;7 8 9 4] %
» x(7:end) % from position 8 to
3x4 matrix
end
b=
ans = 12 14 16
1 2 3 0
»y=[x(1:3); x(4:6); x(7:end)]
4 5 6 2
y=
7 8 9 4
0 2 4
6 8 10
12 14 16

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 21 / 52
Array and Manipulation

Array Manipulation ...

»A= [1 2 3 4;5 6 7 8;9 8 7 6]


»A= [1 2 3;4 5 6] A=
A= 1 2 3 4
1 2 3 5 6 7 8
4 5 6 9 8 7 6
» A(2,3) % row 2, column 3 of A »B= A(2:3,1:3)
ans= 5
B=
» x= A(1,:) % 1st row
5 6 7
x= 1 2 3
9 8 7
» A(:,end) % last column
ans=
»C= A(2:3,end)
3 C=
6 8
6

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 22 / 52
Array and Manipulation

Assigning a value to array

»A= [1 2;3 4];


Adding entries
» A(2,2)= 0 % Assign 0 to A(2,2)
A= »A= [1 2];
1 2 »A= [A;3 4] % Add row [3 4] to
3 0 A
»A(1,:)= [9 9] % Assign [9 9] to A=
the 1st row 1 2
A= 3 4
9 9 »x= [3;5];
3 0 »A= [A x] % Add column vector
»A(:,2)= [1;1] % Assign [1;1] to x to A
2nd column A=
A= 1 2 3
9 1 3 4 5
3 1

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 23 / 52
Array and Manipulation

Special Array
zeros(n), zeros(n,n) % nxn zero matrix

ones(n), ones(n,n) % nxn one matrix

eye(n), eye(n,n) % nxn unity matrix

» A= eye(3) % same as A= eye(3,3)


A=
1 0 0
0 1 0
0 0 1
» x= ones(1,4) % 1x4 vector with elements of 1
x=
1 1 1 1
Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 24 / 52
Array and Manipulation

Special function

[m, n]= size(A) % retruns the size of array

n= length(b) % max(row,column)

m= numel(b) % number of entries


B= reshape(A,n,m) % maps pxq matrix into nxm matrix (pxq=
nxm)

»A= [2 5;-2 3;4 5]; % 3x2 matrix


»[m,n]= size(A)
m=
3
n=
2

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 25 / 52
Array and Manipulation

Special function ...

»b= [1 2 3 4 5];
»A= [2 5;-2 3;4 5]; » m= numel(b) % number of en-
»m= size(A,1) % number of rows tries
m= 3 m= 5
»n= size(A,2) % number of »A= [2 5;-2 3;4 5];
columns » m= numel(A) % number of en-
n= 2 tries
»n= length(A) % max(row,col- m= 6
umn) »B= reshape(A,1,6) % 1x5 vector
n= 3 B= 2 -2 4 5 3 5
»b= [1 2 3 4 5 6]; »B= reshape(A,2,3) % 2x3 ma-
»n= length(b) % max(row,col- trix
umn) B=
n= 6 2 4 3
-2 5 5

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 26 / 52
Array and Manipulation

Example:

Calculate sin(t) and cos(t) and save them with t in array buf, (0 ≤
t ≤ 4π).

buf= [];
for t= 0:pi/30:4*pi
buf= [buf; t sin(t) cos(t)];
end
t= buf(:,1);
y1= buf(:,2);
y2= buf(:,3);

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 27 / 52
Graphs and Figures

Graphs and Figures

plot(x,y,’details’) Plots vector y versus vector x.


plot3(x,y,z) Plots a line in R3 through the points whose coordinates are (x,y,z)
surf(x,y,z) Plots the coloured parametric surface defined by (x,y,z)
surfc(x,y,z) Plots the coloured parametric surface (x,y,z) with contour plot
mesh(x,y,z) Plots the coloured parametric mesh defined by (x,y,z)
meshc(x,y,z) Plots the coloured parametric mesh (x,y,z) with contour plot
contour(x,y,z) Plots the level curves of function z over the coordinates (x,y)

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 28 / 52
Graphs and Figures

’details’ in plot

Colors Symbols Line type


b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
w white v triangle (down)
ˆ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 29 / 52
Graphs and Figures

Change the appearance of a figure

xlabel(’text’) Text on the x-axis


ylabel(’text’) Text on the y-axis
title(’text’) Title text
grid Puts grid on the graph
axis on Displays the axes
axis off Hides the axes
axis square Makes the figure square
axis equal Makes both axes unit measure equal
axis([ xmin xmax ymin ymax]) Sets axes limits
hold on Holds the current plot
legend(’first’, ’second’,. . .) Inserts legend

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 30 / 52
Graphs and Figures

Example: plot and plot3


1
x
MatLab script 0.8 y
z
0.6

0.4

0.2
t=0:0.1:4*pi; 0

x=cos(t); -0.2

y=sin(t); -0.4

-0.6
z=tan(t)./(72*pi);
-0.8
plot(t,x,’-.b’,’LineWidth’,1.5) -1
0 2 4 6 8 10 12 14
hold on
plot(t,y,’*g’,’LineWidth’,1)
plot(t,z,’:hr’,’LineWidth’,1)
legend(’x’,’y’,’z’)

plot3(x,y,z,’LineWidth’,1.5)
grid

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 31 / 52
Graphs and Figures

Example: surf and surfc


MatLab script

[x,y]= meshgrid(0:0.1:5);
z= sin(x).*cos(y);
surf(x,y,z)
title(’Surf’)
xlabel(’x coordinate’)
ylabel(’y coordinate’)
zlabel(’z coordinate’)

surfc(x,y,z)
title(’Surfc’)
xlabel(’x coordinate’)
ylabel(’y coordinate’)
zlabel(’z coordinate’)

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 32 / 52
Graphs and Figures

Example: mesh and meshc


MatLab script

[X,Y]= meshgrid(-8:0.25:8);
F = sqrt(X.ˆ2 + Y.ˆ2) + eps;
Z = sin(F)/2;
mesh(X,Y,Z)
title(’Mesh’)
xlabel(’x coordinate’)
ylabel(’y coordinate’)
zlabel(’z coordinate’)

meshc(X,Y,Z)
title(’Mesh + contour’)
xlabel(’x coordinate’)
ylabel(’y coordinate’)
zlabel(’z coordinate’)

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 33 / 52
Graphs and Figures

Example: mesh versus contour


MatLab script

[X,Y]=meshgrid(-2:.2:2,
-2:.2:3);
Z = X.*exp(-X.ˆ2-Y.ˆ2);
mesh(X,Y,Z)
title(’Mesh’)
xlabel(’x coordinate’)
ylabel(’y coordinate’)
Contour
zlabel(’z coordinate’) 3

2.5

1.5
contour(X,Y,Z) y coordinate 1

title(’Contour’) 0.5

xlabel(’x coordinate’) 0

-0.5
ylabel(’y coordinate’)
-1

zlabel(’z coordinate’) -1.5

-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
x coordinate

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 34 / 52
Graphs and Figures

Exercise: 1

Plot the surface1 p


f (u, v) = u2 + v2
along with its contour plot and contour plot alone; over the
region -8 ≤ u,v ≤8.
1 surfc(u,v,f)
2 contour(u,v,f)

1
Hint: square root in MatLab command = sqrt(x)
Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 35 / 52
Transfer Function

Transfer Function

The transfer function will be presented in both polynomial and


factored form.

Polynomials in MatLab defined using row vectors.

To create a row vector where the elements are the coefficients of


a polynomial, you can represent the polynomial as:

p(t) = an tn + an−1 tn−1 + · · · + a1 t + a0

The vector can be given in MatLab as:

p = [an an−1 ... a1 a0 ]

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 36 / 52
Transfer Function

Example:
Consider the polynomial p(t) = t2 − 2t + 1
1 Define the polynomial on MatLab.
2 Calculate the polynomials roots.
3 Calculate the value of the polynomial for t = 1

» p = [1 -2 1]; % We insert the polynomial as a row vector


» r = roots(p)
r=
1
1
» p_value = polyval(p,1)
p_value=0
Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 37 / 52
Transfer Function

Example:

Consider the symbolic polynomial p(t) = t3 + 2t + 6


1 Convert the symbolic polynomial to polynomial matrix.
2 Convert the polynomial matrix back to the symbolic polynomial.

syms t
sym = tˆ3+2*t+6;
poly = sym2poly(sym) % Convert symbolic polynomial to polyno-
mial matrix
poly = 1 0 2 6
sym_again = poly2sym(poly,t) % Convert back to symbolic polyno-
mial
sym_again = tˆ3 + 2*t + 6

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 38 / 52
Transfer Function

Rational function to partial fractions

Partial fractions simplify finding inverse Laplace transforms by


breaking down complex Laplace transform functions.

A partial fraction expansion of a rational function is given in the


form:
b(s) c1 c2 cn
= + + ··· + + ks
a(s) s − p1 s − p2 s − pn

Where pi , i = 1, . . . , n the poles of the system, ci , i = 1, . . . , n the


residues and ks the quotient.
MatLab conversion command

% Rational to partial fraction % Partial to rational function


» [c,p,k] = residue(num,den) » [num,den] = residue(c,p,k)

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 39 / 52
Transfer Function

Example:

Consider the rational function


s+2
X(s) =
s3 + 4s2 + 3s
I Convert the rational function X(s) to Partial fraction.

MatLab script

num=[1 2];
den=[1 4 3 0];
[c,p,k]=residue(num,den)

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 40 / 52
Transfer Function

Example: ...
Output

c=
-0.1667
-0.5000
0.6667
p=
-3
-1
0
k=
[]

The derived output:


s+2 0.1667 0.5 0.6667
X(s) = =− − +
s3 + 4s2 + 3s s+3 s+1 s
Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 41 / 52
Transfer Function

Exercise: 2

Write a MatLab code2 to find the rational function X(s) that


corresponds to the following sum of partial fractions
3 1.5 −1
X(s) = + + +2
s − 1 s + 4.3 s − 2

I The rational function will be:

2s3 + 6.1s2 − 22.7s − 1.3


X(s) =
s3 + 1.3s2 − 10.9s + 8.6

2
Hint: [num,den] = residue(c,p,k)
Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 42 / 52
Transfer Function

Transfer function representation in MatLab

A transfer function is a rational function that represents a linear


time invariant dynamical system with zero initial conditions.

Transfer function describes the relation between the input and


the output of the system.
Input Output
R(S) G(S) C(S)

C(s) bm sm + bm−1 sm−1 + · · · + b0


= G(s) =
R(s) an sn + an−1 sn−1 + · · · + a0

MatLab command
sys = tf(num,den) % num = [bm bm−1 ... b0 ] and den = [an an−1 ... a0 ]

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 43 / 52
Transfer Function

Transfer function representation in MatLab ...

Transfer function can be also represented by zero-pole-gain


model.

zero-pole-gain model has the following form:


(s − z1 )(s − z2 )...(s − zn )
H(s) = K
(s − p1 )(s − p2 )...(s − pn )

zi represents zeros of the system, pi poles of the system and K is


gain.
MatLab command

sys = zpk(z,p,k)

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 44 / 52
Transfer Function

Transfer function representation in MatLab ...


MatLab conversion command

% tf model to zpk model % zpk model to tf model


» [z,p,k] = tf2zp(num,den); » [num,den] = zp2tf(z,p,k);
» sys = zpk(z,p,k) » sys = tf(num,den)

Another way of representing a transfer function, is by assigning a


variable, for example ’s’, as a variable of the transfer function.
Then, simply type the transfer function in the command or editor
window.

MatLab command

s = tf(’s’); s = zpk(’s’)

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 45 / 52
Transfer Function

Example:
1 For the following transfer function
s+1
H(s) =
s2 + 3s + 1

I Write the MatLab code using tf(num,den)

I Convert the obtained tf model to zpk model

MatLab script

num = [1 1];
den = [1 3 1];
sys = tf(num,den) % Create transfer function
sys_zpk = zpk(sys) % Convert to zpk model

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 46 / 52
Transfer Function

Exercise: 3
1 For the following transfer function
s+2
G(s) =
(s + 1)2 (s + 3)

I Write the MatLab code using zpk(z,p,k)

I Convert the obtained zpk model to tf model

2 For both the following given models by assigning a variable ’s’,


as a variable of the transfer function write a MatLab script3 .
s+1
G1 (s) = 2
s + 2s + 1
(s + 2)(s − 1)
G2 (s) =
(s + 3)2 (s − 5)
3
Hint: s = tf(’s’) and s = zpk(’s’)
Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 47 / 52
Transfer Function

System Characteristics and Responses

Basic transfer function MatLab command

pole(sys) Poles of the transfer function


zero(sys) Zeros of the transfer function
pzmap(sys) Pole-Zero map of the transfer function
[Wn,Z]=damp(sys) Returns natural frequency and damping factor
step(sys) Plots the step response of the system
data=stepinfo(’sys’) Computes the step response characteristics
impulse(sys) Plots the impulse response of the system

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 48 / 52
Transfer Function

Example:

Find the poles and zeros of the following transfer function and
plot them in the Complex plane.

5(s2 + 6s + 10)
G(s) =
(s + 1)(s2 + 4s + 5)

s=tf(’s’);
sys=(5*(sˆ2 + 30*s + 50))
/(sˆ3 + 5*sˆ2 + 9*s + 5);
pole(sys)
zero(sys)
pzmap(sys);
grid

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 49 / 52
Transfer Function

Example:

Consider the following transfer function; and find poles and zeros of
the system then plot the step and impulse response.

s2 + 2s + 1
G(s) =
s3 + 3.8s2 + 8.76s + 5.96

sys=tf([1 2 1],[1 3.8 8.76 5.96])


p=pole(sys)
z=zero(sys)
impulse(sys)
hold on
step(sys)
title(’Step and impulse response’)
legend(’Imp_resp’,’Stp_resp’)
grid

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 50 / 52
Transfer Function

Exercise: 4

Consider a system with transfer function


9(s + 2)
G(s) =
(s + 3)(s2 + 4s + 5)

1 Find the poles and zeros of the system


2 Plot poles and zeros of the system in the complex plane
3 plot the impulse and step response of the system

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 51 / 52
Transfer Function

Thank you!

Esaias. A (WU-KIoT) Introduction to Control System using MatLab March 19, 2024 52 / 52

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy