18.45.18.05.2023 Control Notes Time Response MATLAB Solution Lect 3.1
18.45.18.05.2023 Control Notes Time Response MATLAB Solution Lect 3.1
LECTURE 3.1
dsolve('D2y+10*Dy+100*y=0')
DSOLVE example 2
Use of DSOLVE to get general solution to DE with integration constants computed from Initial
Conditions (IC). IC: at time t=0, y(0)=1 and Dy(0)=0
DSOLVE example 3 Use of DSOLVE to get Total solution to DE with integration constants
computed from Initial conditions.
IC: at time t=0, y(0)=1 and Dy(0)=0 and particular solution for given forcing function
f(t)=3sin(2t)
Plot the resulting analytic time function by the use of MATLAB ‘plot’
command.
Spring-mass-damper forced response. Forced Response to zero Initial Condition.
Analytic time function for the response known, derived, or given spring constant k=2,
spring mass m=1kg, natural frequency 𝜔n=Ök/m, dumping coefficient z=0.5, b=2*z*𝜔n
step response with f = 10N.
t=[0:0.01:5];
k=2; m=1; z=0.5;
b=2*z*𝜔n ; f = 10;
𝜔d= 𝜔n *Ö(1-z^2); damped natural frequency
y=(f/k)*(1-(𝜔n/𝜔d)*( exp(-z*𝜔n*t)*sin(𝜔d*t+acos(zeta)) ))
sys1=tf(numg,deng)
sys2=tf(numc,denc)
sys3=series(sys1,sys2)
syms s
num = [80.8];
den = [1 2 101];
G=tf(num,den)
Now to create ‘bode’ plot in MATLAB with ‘omega’ limits, by using the ‘bode’
command:
bode(G,{ωL , ωU }) where ωL is the lower frequency limit, and ωU is the upper frequency
limit.
G=numg/deng
sysg=tf(numg,deng)
z=zero(sysg)
generate zeros of TF
Conclusions
The MATLAB help facility can provide additional information on the
use of these individual commands. These notes have concentrated on the
application of these select commands for control systems analysis and
design. The elimination of the distraction of intermediate calculations in
2) Dorf, R. C., “Modern Control Systems”, Ninth edition, Prentice Hall, 2001
3) Kuo, B. C. and Golnaraghi, F., “Automatic Control Systems”, Eighth Edition, Wiley,
2003
5) Magrab, E. B., Azarm, S., Balakrishnan, B., Duncan, J., Herold, K., and Walsh, G.,
“An Engineer’s Guide to MATLAB”, Prentice Hall, 2000
6) Etter, D. M., Kuncicky, D. C., and Hull, D., “Introduction to Matlab 6”, Prentice Hall
Engineering Source, 2002
Contents
Ø Solution via State Space
Ø The State Transition Matrix
Ø Zero Input
• Alternate Derivation of the State Transition Matrix
• Properties of the State Transition Matrix
Ø Zero State
Ø Complete Response
Zero input and zero state solutions of a system can be found if a state
space representation of the system is known. Before solving an example,
first develop a generalized technique for finding the zero input and zero
state solutions of a problem. This is followed by several examples.
Recall that a state space system is defined by the equations
where q is the state vector, A is the state matrix, B is the input matrix, u is
the input, C is the output matrix, D is the direct transition (or feedthrough)
matrix, and y is the output. In general, single input and single output (SISO)
system is assumed so u(t), y(t) and D are defined as scalars. The
techniques are general in obvious ways to systems with multiple inputs and
multiple outputs.
Before considering the solution of a problem, first define the state transition
matrix and some of its properties. The state transition matrix is an important
part of both the zero input and the zero state solutions of systems
where I is the identity matrix. The time domain state transition matrix, φ(t),
is simply the inverse Laplace Transform of Φ(s).
To find φ(t), take the inverse Laplace Transform of every term in the matrix
MATLAB can be used to find the zero input response of a state space system:
Zero Input
Develop a method for finding the zero input solution to a system defined in
state space. The system is defined as;
The solution for y(t) is found in a straightforward way from the output
equation;
with
and
Solution:
For the given A matrix, Φ(s) and φ(t) were calculated previously (above);
\
So
and
(Taylor
expansion
of
exponential)
Examining the third row of the table, a matrix exponential has been
introduced that is exactly analogous to the scalar exponential, and this
matrix exponential is in the solution of the first order matrix differential
equation:
shows that
Solution:
Since
then
It is perhaps not surprising that the series form of the matrix exponential
yields such a compact closed form solution, but this makes it possible to evaluate
eAt (and φ(t)) precisely and efficiently.
From the matrix exponential definition of the state transition matrix we can
derive several properties.
Zero State
Finding the zero state response of a system given a state space
representation is a bit more complicated. In the Laplace Domain the
response is found by first finding the transfer function of the system.
In the time domain, this last equation (multiplication in the Laplace domain),
is just a convolution (the asterisk (*) denotes convolution):
Note: this last equation assumes a single input system. For multi-input systems
the u(t) term must stay to the right of B.
Find the zero input solution (qzi(t) and yzi(t)) for the system defined by:
with
and
Solution:
First, find the transfer function from the state space representation
so
n =
0 -1.0000 1.0000
d =
1 3 2
Also
so
The partial fraction expansion can be done by hand or with MATLAB. The MATLAB
solution is shown.
r =
0.7500
-2.0000
-1.2500
0.5000
p =
-2
-1
k = []
Complete Response
Example: Complete Response from State Space (2x2)
Find the response for the system defined by:
with
and
Solution:
The zero input problem was solved previously
Note that the complete response converges to the zero state response at long times as the
zero input response decays to zero.
Find the output if the system starts at rest (the velocity is zero) but xout(0-)=0.05 and
xin(t)=0.1·γ(t).
Solution:
First develop a state space model. Techniques for doing so are
discussed earlier. Start from the system transfer function:
From the top row of the state variable equation we see that:
or
Start by finding the state transition matrix. This could be done by hand, or use
MATLAB's symbolic toolbox:
>> syms s
>> Phi=inv(s*eye(2)-A)
Phi =
with
>> Yzi=C*Phi*q0
Yzi =
>> pretty(simple(Yzi))
s + 5
-----------------
20 (s + 5 s + 6)
At this point perform a partial fraction expansion, using MATLAB to do the work
r =
-0.1000
0.1500
p =
-3.0000
-2.0000
k = []
So
As expected this agrees with the solution obtained using the transfer function above.
Start by finding the transfer function, which was derived at the start of the problem.
Complete Solution:
The complete response is simply the sum of the zero input and zero state response.
Multiplication by eαt L[f (t)eαt ] = F(s − α) for any real or complex number α
Multiplication by sin(ω0 t) L[f (t) sin(ω0 t)] = (j/2)[F(s + jω0 ) − F(s − jω0 )]
Multiplication by cos(ω0 t) L[f (t) cos(ω0 t)] = (1/2)[F(s + jω0 ) + F(s − jω0 )]
! "
d
Differentiation in the time domain L f (t) = sF(s) − f (0)
dt
# $
d2 d
Second derivative L 2
f (t) = s2 F(s) − sf (0) − f (0)
dt dt
! n "
d d d n−1
nth derivative L n f (t) = sn F(s) − sn−1 f (0) − sn−2 f (0) − · · · − n−1 f (0)
dt dt dt
!% t "
1
Integration L f (τ)dτ = F(s)
0 s
Convolution in the time domain L[f (t) ∗ g(t)] = F(s)G(s)
Initial-value theorem f (0) = lim sF(s)
s→∞
Final-value theorem If f (t) has a finite limit f (∞) as t → ∞, then f (∞) = lim sF(s)
s→0
In Equations 2.20 and 2.21, m and n are positive integers and the coefficients bm , bm−1 , . . . , b1 , b0 and
an−1 , . . . , a1 , a0 are real numbers. In Equation 2.19, it is assumed that N(s) and D(s) do not have any
common factors. If there are common factors, they should always be cancelled. Also note that the poly-
nomial D(s) is monic; that is, the coefficient of sn is equal to 1. A rational function F(s) can always be
written with a monic denominator polynomial D(s). The integer n, which is the degree of D(s), is called
the order of the rational function F(s). It is assumed that n ≥ m, in which case F(s) is said to be a proper
rational function. If n > m, F(s) is said to be strictly proper.
Given a rational transform F(s) = N(s)/D(s) with N(s) and D(s) defined by Equations 2.20 and 2.21,
let z1 , z2 , . . . , zm denote the roots of the polynomial N(s), and let p1 , p2 , . . . , pn denote the roots of D(s);
that is, N(zi ) = 0 for i = 1, 2, . . . , m and D(pi ) = 0 for i = 1, 2, . . . , n. In general, zi and pi may be real or
complex numbers, but if any are complex, they must appear in complex conjugate pairs. The numbers
z1 , z2 , . . . , zm are called the zeros of the rational function F(s) since F(s) = 0 when s = zi for i = 1, 2, . . . , m;
and the numbers p1 , p2 , . . . , pn are called the poles of F(s) since the magnitude |F(s)| becomes infinite as
s approaches pi for i = 1, 2, . . . , n.
If F(s) is strictly proper (n > m) and the poles p1 , p2 , . . . , pn of F(s) are distinct (nonrepeated), then
F(s) has the partial fraction expansion
c1 c2 cn
F(s) = + +···+ , (2.22)
s − p1 s − p2 s − pn
Eng. Prof. Mwangi Mbuthia May 2023 Page 29 of 32
where the ci are the residues given by