0% found this document useful (0 votes)
4 views21 pages

Tutorial 4

The document provides instructions on using MATLAB to model and simulate transfer-function and state-space systems, focusing on generating step and impulse responses. It includes MATLAB commands for defining systems and plotting responses, along with examples for specific systems. Additionally, it outlines tasks for obtaining and plotting responses for given mechanical systems.

Uploaded by

osa34074
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)
4 views21 pages

Tutorial 4

The document provides instructions on using MATLAB to model and simulate transfer-function and state-space systems, focusing on generating step and impulse responses. It includes MATLAB commands for defining systems and plotting responses, along with examples for specific systems. Additionally, it outlines tasks for obtaining and plotting responses for given mechanical systems.

Uploaded by

osa34074
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

Modeling & simulation

MEC 242
MATLAB representation of transfer-function systems.

Step response
If num and den (the numerator and denominator of a transfer function) are known,
we may define the system by
sys = tf(num,den)

Then, a command such as


step(sys) or step(num,den)

will generate a plot of a unit-step response and will display a response curve on the screen.
MATLAB representation of transfer-function systems.
Impulse response.
The impulse input is usually denoted by a vertical arrow, to indicate that it has a very short duration and a very large height.

The unit-impulse response of a dynamic system defined


in the form of the transfer function may be obtained by use of one of the following MATLAB
commands:

impulse(sys) or impulse(sys,t)
impulse(num,den) or impulse(num,den,t)
If we wish MATLAB to compute the response every at seconds and plot the
response curve for 0 ≤ t ≤ T
we enter the statement

and use the command

step(sys, t) or step(nurn,den,t)
MATLAB representation of state-space.

Step response
We first define the system with

sys = ss(A,B,C,D)

Then, a command such as


step(sys) or step(A,B,C,D)

will generate a plot of a unit-step response.


MATLAB representation of transfer-function systems.
Impulse response.
The unit-impulse response of a dynamic system defined
in a state space may be obtained with the use of one of the following MATLAB
commands:

sys = ss(A,B,C,D); impulse(sys),


1.
A. Obtain the impulse and unit step response for the system.
B. Write MATLAB code to plot the impulse and unit step response for
the system.
1
𝐺 𝑠 =
𝑠+1
1.
𝑋 𝑠 1
• ==
𝑈 𝑠 𝑠+1
1
•𝑋 𝑠 = 𝑈 𝑠
𝑠+1
• 𝑖𝑛 𝑐𝑎𝑠𝑒 𝑜𝑓 𝑖𝑚𝑝𝑢𝑙𝑠𝑒 𝑖𝑛𝑝𝑢𝑡: 𝑢 𝑡 = 𝛿 𝑡 → 𝑈 𝑠 = 1
1
•𝑋 𝑠 =
𝑠+1
•𝑥 𝑡 = 𝑒 −𝑡
1.
num=[1];
dem=[1 1];
g=tf(num,dem);
impulse(g)
1.
1
• 𝑖𝑛 𝑐𝑎𝑠𝑒 𝑜𝑓 𝑢𝑛𝑖𝑡 𝑠𝑡𝑒𝑝 𝑖𝑛𝑝𝑢𝑡: 𝑢 𝑡 = 1 → 𝑈 𝑠 =
𝑠
1 1 𝑎 𝑏
•𝑋 𝑠 = = +
𝑠 𝑠+1 𝑠 𝑠+1
• 𝑎 = 1, 𝑏 = −1
1 1
• 𝑋 𝑠 = −
𝑠 𝑠+1
•𝑥 𝑡 =1 − 𝑒 −𝑡
1.
num=[1];
dem=[1 1];
g=tf(num,dem);
step(g)
2.
• Consider the mechanical system shown in
Figure, The external force 𝑢(𝑡) is the input to
the system, and the displacement 𝑦(𝑡) of the
mass is the output.
A. Obtain the impulse and unit step response for
the system.
B. Write MATLAB code to plot the impulse and
unit step response for the system.
• 𝑊ℎ𝑒𝑛: 𝑚 = 1𝑘𝑔, 𝑏 = 1𝑁. 𝑠/𝑚, 𝑘 = 1𝑁/𝑚,
2.
• 𝑚𝑥ሷ + 𝑏𝑥ሶ + 𝑘𝑥 = 𝑢
• 𝑚𝑠 2 + 𝑏𝑠 + 𝑘 𝑋(𝑠) = 𝑈 𝑠
1
𝑋 𝑠 1 1
• = = 𝑚
𝑏 𝑘 =
𝑈 𝑠 𝑚𝑠 2 +𝑏𝑠+𝑘 𝑠2 +𝑚𝑠+𝑚 𝑠2 +𝑠+1
1
•𝑋 𝑠 = 𝑈 𝑠
𝑠2 +𝑠+1
2.

num=[1];
dem=[1 1 1];
g=tf(num,dem);
impulse(g)
2.
num=[1];
dem=[1 1 1];
g=tf(num,dem);
step(g)
3.
• Write MATLAB code to plot the unit step response for the following
systems:
9
i. 𝐺 𝑠 =
𝑠2 +9𝑠+9
9
ii. 𝐺 𝑠 = 𝑠2 +6𝑠+9
9
iii. 𝐺 𝑠 = 𝑠2 +2𝑠+9
9
iv. 𝐺 𝑠 = 𝑠2 +9
i.
t=[0:0.001:10];
num=[9];
dem=[1 9 9];
sys=tf(num,dem);
y=step(sys,t);
plot(t,y)
grid
axis([0 10 0 1.5])
title('step response of system')
xlabel('t(sec)')
ylabel('y(meter)')
ii.
t=[0:0.001:10];
num=[9];
dem=[1 6 9];
sys=tf(num,dem);
y=step(sys,t);
plot(t,y)
grid
axis([0 10 0 1.5])
title('step response of system')
xlabel('t(sec)')
ylabel('y(meter)')
iii.
t=[0:0.001:10];
num=[9];
dem=[1 2 9];
sys=tf(num,dem);
y=step(sys,t);
plot(t,y)
grid
axis([0 10 0 1.5])
title('step response of system')
xlabel('t(sec)')
ylabel('y(meter)')
iV.
t=[0:0.001:10];
num=[9];
dem=[1 0 9];
sys=tf(num,dem);
y=step(sys,t);
plot(t,y)
grid
axis([0 10 0 2])
title('step response of system')
xlabel('t(sec)')
ylabel('y(meter)')
Thank you

You might also like