Sie sind auf Seite 1von 23

State Variables and Linear Time-Invariant Systems

CEE 541. Structural Dynamics


Department of Civil and Environmental Engineering
Duke University

Henri P. Gavin
Fall 2014

1 Linearity and Time Invariance

A system G that maps an input u(t) to an ouput y(t) is a linear system if and
only if
(1 y1 (t) + 2 y2 (t)) = G[1 u1 (t) + 2 u2 (t)] (1)
where y1 = G[u1 ], y2 = G[u2 ] and 1 and 2 are scalar constants.

A system G that maps an input u(t) to an ouput y(t) is a time-invariant


system if and only if
y(t to ) = G[u(t to )] . (2)

Systems described by

x(t) = Ax(t) + Bu(t) , x(0) = xo (3)


y(t) = Cx(t) + Du(t) (4)

are linear and time-invariant.

variable description dimension


x state vector n by 1
u input vector r by 1
y output vector m by 1
A dynamics matrix n by n
B input matrix n by r
C output matrix m by n
D feedthrough matrix m by r
2 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

2 Example: a spring-mass-damper oscillator

An externally-forced spring-mass-damper oscillator is described by

mr(t) + cr(t) + kr(t) = f (t) , r(0) = do , r(0) = vo . (5)

Assuming a solution of the form r(t) = ret ,

(m2 + c + k)r = 0 .

This equation is valid for r = 0, the trivial solution, and


v
c u c2 k
u
= t
2m 4m m
Note that can be complex, = . Now, defining the natural frequency

n2 = k/m, and the damping ratio = c/(2 mk), we find c/(2m) = n , so,
q
= n 2 n2 n2
q
= n n 2 1 (6)

and if < 1, the root may be written


q
= n n 1 2 .

( = 1) Note that if > 0 then < 0 and the system is stable.

The second-order ordinary differential equation (5) may be written as two


first-order ordinary differential equations, by defining a state vector of the
position and velocity, x = [r r]T .

d r 0 1 r 0 r(0) do
= + f (t) , = (7)
dt r k/m c/m r 1/m r(0) vo
In terms of a desired response from this system, we may be interested in the
force on the foundation, fF , and the acceleration of the mass, both of which
can be computed directly through a linear combination of the states and the
input.
f F =
k c r +
0 f (t)
(8)
r k/m c/m r 1/m

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 3

A single degree of freedom oscillator as well as many other types of dynamical


systems may be described in a general sense using state variable descriptions,

x(t) = Ax(t) + Bu(t) , x(0) = xo


y(t) = Cx(t) + Du(t) .

3 Free Response

If u(t) = 0, then the free response y(t) of the system to initial conditions xo
is
y(t) = CeAt xo , (9)
where eAt is called a matrix exponential.
In Matlab, y(:,p)=C*expm(A*t(p))*xo;

4 Unit Impulse Response Function

If xo = 0 and the input is a unit impulse, u(t) = Im (t), the responses y(t) of
the system are called the unit impulse response function, H(t),

H(t) = CeAt B . (10)

The set of free responses is richer than the set of unit impulse responses.
In Matlab, H(p,:,:)=C*expm(A*t(p))*B;

5 Forced Response

The forced response of a linear time invariant system is


Z t
y(t) = CeAt xo + C eA(t ) Bu( ) d + Du(t). (11)
0

An efficient method for computing y(t) for a arbitrary inputs u(t) is provided
in the last sections of this document.

CC BY-NC-ND H.P. Gavin


4 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

6 The Matrix Exponential

The matrix exponential is defined for real square matrices, Ann , as



X
eA = Ak /k! = I + A + AA/2 + AAA/6 + AAAA/24 + (12)
k=0

Properties of the matrix exponential:

If A = AT then eA > 0.

If A = AT then [eA ][eA ]T = I

eAt eBt = e(A+B)t


T
[eA ]T = eA

[eA ]1 = eA
1
eSAS = SeA S 1 for any square matrix Snn .
1 1 1
eSAS = I + SAS 1 + SAS 1 SAS 1 + SAS 1 SAS 1 SAS 1 +
2 6
1 1
= SS 1 + SAS 1 + SAAS 1 + SAAAS 1 +
2 6
= S[I + A + AA/2 + AAA/6 + ]S 1
1
eSAS = SeA S 1 . (13)

d At
dt e = AeAt

1 1 1
eAt = I + At + AAt2 + AAAt3 + AAAAt4 +
2 6 24
d At 1 1
e = A + AA + AAAt2 + AAAAt3 +
dt 2 6
1 1 1
= A[I + At + AAt2 + AAAt3 + AAAAt4 + ]
2 6 24
d At
e = AeAt (14)
dt

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 5
R t A
A 0 e d = eAt I
Z t Z t d A
A eA d = e d
0 0 d
t

= eA 0
At
= e eA0
= eAt I
Z t
A eA d = eAt I (15)
0
Z t
A
A e d = eAt I (16)
0

= A1 (eAt I)
R t A(t )
0e d
Z t Z t
eA(t ) d = eAt eA d
0 0
At t A
Z
= e e d
0
= eAt (A1 ) eAt I
 

= eAt A1 eAt + eAt A1


= A1 AeAt A1 eAt + A1 AeAt A1
1 1
= A1 eAAA t At
e + A1 eAAA t

= A1 eAt eAt + A1 eAt


= A1 + A1 eAt
1 At
 
= A e I (17)
Z t
= eA d (18)
0

The solution to x(t) = Ax(t) + Bu(t), x(0) = xo , for t 0 is


Z t
At
x(t) = e xo + eA(t ) Bu( ) d . (19)
0

As a special case of the above, if the input to the system is v(t) where
v is a m by 1 vector and (t) is the Dirac delta function, and if xo = 0,
then the output y(t) is called the unit impulse response function, h(t).

h(t) = CeAt Bv . (20)

CC BY-NC-ND H.P. Gavin


6 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin


q
With definitions of the natural frequency, n = k/m, the damping ratio,

q
= c/(2 mk), and the damped natural frequency, d = n | 2 1|, let

0 1 0 1
A= = 2
. (21)
k/m c/m n 2n

For this dynamics matrix, the matrix exponential depends on the damping
ratio, , as follows:
damping damping ratio eAt " #
1
At cos n t n sin n t
undamped =0 e =
n sin n t cos n t

cos d t + sin d t 1
d sin d t
1 2
underdamped 0<<1 eAt = en t
cos d t

d sin d t sin d t
1 2 1 2

 
At n t 1 + n t t
critically damped =1 e =e
n2 t 1 n t

cosh d t + sinh d t 1
d sinh d t
1 2
overdamped >1 eAt = en t
cosh d t 2

2d sinh d t sinh d t
1 1

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 7

7 Eigenvalues and Diagonalization

Consider the dynamics matrix A of a linear time invariant, (LTI) system.


If the input, u(t) is zero, then x = Ax. Assuming a solution of the form
x(t) = xet , and substituting this solution into x = Ax, results in:

xet = Axet

or
x = Ax , (22)
which is a standard eigenvalue problem, in which x is the eigen-vector and is
the eigen-value. If A is a nn matrix, then there are n eigen-values, 1 , , n
and n associated eigen-vectors, x1 , , xn . For the dynamics matrix given in
equation (7), there are two eigenvalues.
v
c c2 k
u
u
1,2 =
t
(23)
2m 4m
q
m
= n n 2 1 (24)

The dynamics matrix contains all the information required to determine the
natural frequencies and damping ratios of the system.

The n eigen-vectors can be assembled, column-by-column into a matrix,

X = [x1 x2 xn ] .

Pre-multiplying the eigen-problem by X 1 ,



1
X 1
AX = X 1
X = diag(i ) =

...



n
This is called a diagonalization of the dynamics matrix A.

Now, consider the linear transformation of coordinates, x(t) = Xq(t),


q(t) = X 1 x(t). Substituting this change of coordinates into equation (3),

X q(t) = AXq(t) + Bu(t),

CC BY-NC-ND H.P. Gavin


8 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

and pre-multiplying by X 1

q = X 1 AXq + X 1 Bu,

or

1
q =

...
q + X 1 Bu , q(0) = X 1 xo


n
q = Aq + Bu , q(0) = X 1 xo (25)
y = C Xq + Du
y = Cq + Du (26)

The n differential equations qi = i qi + Bi u are uncoupled. The state qi (t) is


independent of all the other states qj (t), j 6= i. Note that if is complex, so
are X, A, B, and C.

Consider one of the un-coupled equations from equation (25), for the unforced
case u = 0
qi (t) = i qi (t) , qi (0) = 1 .
This equation has a solution

qi (t) = ei t ,

where i is, in general, a complex value,

i = i i ,

and qi + qi is real-valued.
1 i t 1 i t
qi (t) + qi (t) = e + e
2 2
1 i t 1
= e (cos i t + sin i t) + ei t (cos i t sin i t)
2 2
i t
= e cos i t ,

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 9

8 Transfer Function and Frequency Response Function

Taking the Laplace transform of equation (3), (and ignoring the effects of
initial conditions) gives
sX(s) = AX(s) + BU (s) , (27)
Y (s) = CX(s) + DU (s) , (28)
which can be written as Y (s) in terms of U (s) as follows,
Y (s)
= H(s) = C[sI A]1 B + D. (29)
U (s)
This is the transfer function of the linear dynamic system. The same may be
carried out on equations (25) and (26), resulting in
Y (s)
= H(s) = C[sI A]1 B + D.
U (s)
Recall that the matrix A = diag(i ), so, H(i ) = . The eigen-values i of
A are called the poles of the system.

Equation (29) may be used to determine the complex-valued frequency re-


sponse function of any dynamic system, by evaluating the transfer function
along the line s = .
Y ()
= H() = C[I A]1 B + D. (30)
U ()
Assuming that the inputs u(t) are sinusoidal with frequency and unit am-
plitude, the magnitude of the frequency response function,
q
|H()| = <[H()]2 + =[H()]2
gives the amplitude of the responsess y(t). The phase of H(),

=[H()]
H() = arctan
<[H()]
gives the phase angle between the input u(t) and the output y(t). So if
u(t) = cos(t), then y(t) = |H()| cos(t + H()).

In Matlab, [mag,pha] = bode(A,B,C,D); generates plots of |H()| and


H() for a system defined by matrices A, B, C, and D.

CC BY-NC-ND H.P. Gavin


10 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

9 Transforming Continuous Time Systems to Discrete Time Systems (I)

Making a substitution of t = t into equation (19), and specifying that


u( ) = u(ti ) = ui for 0 t,
Z t
x(t) = eAt xi + eA(t ) d Bui
0
At 1 At
 
= e xi + A e I Bui ,

and defining xi+1 = x(t),

eAt xi + A1 eAt I B ui ,
h i h   i
xi+1 =
= [Ad ] xi + [Bd ] ui (31)

where Ad and Bd are the discrete-time dynamics matrix and the discrete-time
input matrix, Ad = eAt and Bd = A1 (Ad I)B.

Note that Bd exists even though A may not be invertible. Consider the
diagonalization A = X 1 X. The inverse of A may be expressed A1 =
X 1 1 X, where X X 1 = I. So,

A1 (eAt I) = X 1 1 X X 1 (et I)X = X 1 1 (et I)X,

which contains diagonal terms (ei 1)/i , and


ei 1
lim =1.
i 0 i
To compute Bd without inverting A, note the following:
t2 t3 t4
eAt I = At +AA + AAA + AAAA +
2 6 24
t2 t3 t4
A1 (eAt I) = t + A+ AA + AAA +
2 6 24
1 At t2 t3 t4
Bd = A (e I)B = tB + AB + AAB + AAAB + ,
2 6 24
and, if
Ann Bnr
M = , (32)
0rn 0rr

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 11

then,

M t t2 t3 t4
e = I + tM + MM + MMM + MMMM +
2 6 24
2 3

A B t AA AB t AAA AAB +
= I + t + +
0 0 2 0 0 6 0 0
t2 t2 t3

I + tA + 2 AA + tB + 2 AB + 6 AAB +
= ,
0 0
so
Ad Bd
eM t = , (33)
0 0
and the discrete time dynamics matrix Ad and input matrix Bd may be com-
puted using a single matrix exponential computation.

In Matlab:

[n,r] = size(B);
M = [ A B ; zeros(r,n+r) ];
eMdt = expm(M*dt);
Ad = eMdt(1:n,1:n);
Bd = eMdt(1:n,n+1:n+r);

With the matrices Ad and Bd , the transient response may be computed digi-
tally using equation (31).

x(:,1) = x0;
for p=1:points-1
x(:,p+1) = Ad * x(:,p) + Bd * u(:,p);
end

CC BY-NC-ND H.P. Gavin


12 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

10 Transforming Continuous Time Systems to Discrete Time Systems (II)

Making a substitution of t = t into equation (19), and specifying that the


input changes linearly over a time increment, t,
1
u( ) = u(ti ) + (u(ti+1 ) u(ti )) = ui + u0i for 0 t , (34)
t
gives
Z t
x(t) = eAt xi + eA(t ) B u( ) d
0
Z t Z t
= e At
xi + eA(t )
d B ui + eA(t ) B u0i d
0 0
At
xi + A1 eAt I B ui + A 2 At
I At B u0i .
   
= e e
Defining xi+1 = x(t),
eAt xi + A1 eAt I B ui + A2 eAt I At B u0i ,
h i h   i h   i
xi+1 =
= [Ad ] xi + [Bd ] ui + [Bd0 ] u0i (35)
where Ad , Bd , and Bd0 are the discrete-time dynamics matrix and the discrete-
time input matrices. If u( ) is constant within the time increment, then u0i = 0
and Bd0 need not be computed.

The input matrices Bd and Bd0 exist even though A may not be invertible. To
compute Bd without inverting A, note the following:
At t2 t3 t4
e I = At + AA + AAA + AAAA +
2 6 24
t2 t3 t4
A1 (eAt I) = t + A+ AA + AAA +
2 6 24
1 At t2 t3 t4
Bd = A (e I)B = tB + AB + AAB + AAAB + ,
2 6 24

and,
At t2 t3 t4
e I At = AA + AAA + AAAA +
2 6 24
2 At t2 t3 t4
A (e I At) = + A+ AA +
2 6 24
0 2 At t2 t3 t4
Bd = A (e I At)B = B+ AB + AAB + ,
2 6 24

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 13

If
Ann Bnr 0nr

M(n+2m)(n+2r) = (36)

0rn 0rr Irr
,

0rn 0rr 0rr
then,
t2 t3 t4
eM t = I + tM + MM + MMM + MMMM +
2 6 24

A B 0 2 AA AB B 3 AAA AAB AB
t t
= I + t 0 0 I + 0 0 0 + 0 0 0 +

2 6

0 0 0 0 0 0 0 0 0
t2 t2 t3 t2 t3

I + tA + 2 AA + tB + 2 AB + 6 AAB + 2 B + 6 AB +
= 0 0 0 ,

0 0 0
so,
0
Ad Bd Bd
M t
e = (37)


0 0 0 ,

0 0 0
and the discrete time dynamics matrix Ad and input matrices Bd and Bd0 may
be computed using a single matrix exponential computation.

In Matlab:

[n,m] = size(B);
M = [ A B zeros(n,r) ; zeros(r,n+r) eye(r) ; zeros(r,n+2*r) ];
eMdt = expm(M*dt);
Ad = eMdt(1:n,1:n);
Bd = eMdt(1:n,n+1:n+r);
Bd_ = eMdt(1:n,n+r+1:n+2*r);
Bd0 = Bd - Bd_ / dt;
Bd1 = Bd_ / dt;

With the matrices Ad , Bd , and Bd0 , the transient response may be computed
digitally using equation (35).

x(:,1) = x0;
for p=1:points-1
x(:,p+1) = Ad * x(:,p) + Bd0 * u(:,p) + Bd1 * u(:,p+1);
end

CC BY-NC-ND H.P. Gavin


14 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

lsym.m http://www.duke.edu/hpgavin/lsym.m
1 function y = lsym (A ,B ,C ,D ,u ,t , x0 )
2 % LSYM S i m u l a t i o n o f a c o n t i n u o u s time l i n e a r s ys t e m t o a r b i t r a r y i n p u t s .
3 % y = LSYM(A, B, C,D, u , t , x0 ) computes t h e time r e s p o n s e o f t h e l i n e a r s y st e m :
4 % .
5 % x = Ax + Bu
6 % y = Cx + Du
7 %
8 % A : r e a l n by n dynamics matrix
9 % B : r e a l n by r i n p u t matrix
10 % C : r e a l m by n o u t p u t matrix
11 % D : r e a l m by r feedthrough matrix
12 % u : real r by p m a t r i x o f sampled i n p u t s
13 % t : r e a l 1 by p v e c t o r o f u n i f o r m l y s p a c e d p o i n t s i n time
14 % x0 : r e a l n by 1 v e c t o r o f i n i t i a l s t a t e s , d e f a u l t s t o z e r o
15 % y : r e a l m by p m a t r i x o f t h e sy s te m o u t p u t s
16 %
17 % LSYM r e t u r n s a semia n a l y t i c e x a c t s o l u t i o n u s i n g a
18 % c o n t i n u o u s tod i s c r e t e c o n v e r s i o n b a s e d on t h e m a t r i x e x p o n e n t i a l ,
19 % and assuming u i s a l i n e a r ramp b e t w e e n sample p o i n t s .
20
21 [n ,r , m ] = abcddim (A ,B ,C , D ); % d e t e r m i n e and c h e c k c o m p a t a b i l i t y o f m a t r i x dim s
22
23 points = s i z e (u ,2); % number o f d a t a p o i n t s
24
25 y = zeros (m , points ); % memory a l l o c a t i o n f o r t h e o u t p u t
26
27 i f ( nargin == 7 )
28 x = x0 ; % i n i t i a l conditions for the state
29 else
30 x = zeros (n ,1); % i n i t i a l c o n d i t i o n s are zero
31 end
32
33 dt = t (2) - t (1); % uniform times t e p v a l u e
34
35 M = [ A B zeros (n , r ) ; zeros (r , n + r ) eye( r ) ; zeros (r , n +2* r ) ];
36 eMdt = expm( M * dt ); % matrix e x p o n e n t i a l
37 Ad = eMdt (1: n ,1: n ); % d i s c r e t e time dynamics m a t r i x
38 Bd = eMdt (1: n , n +1: n + r ); % d i s c r e t e time i n p u t m a t r i x
39 Bd_ = eMdt (1: n , n + r +1: n +2* r ); % d i s c r e t e time i n p u t m a t r i x
40 Bd0 = Bd - Bd_ / dt ; % d i s c r e t e time i n p u t m a t r i x f o r time p
41 Bd1 = Bd_ / dt ; % d i s c r e t e time i n p u t m a t r i x f o r time p+1
42
43 y (: ,1) = C * x + D * u (: ,1);
44
45 f o r p = 1: points -1
46
47 x = Ad * x + Bd0 * u (: , p ) + Bd1 * u (: , p +1);
48
49 y (: , p +1) = C * x + D * u (: , p +1);
50
51 end

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 15

abcddim.m http://www.duke.edu/hpgavin/abcddim.m
1 function [n , r , m ] = abcddim (a , b , c , d )
2 % Usage : [ n , r , m] = abcddim ( a , b , c , d )
3 %
4 % Check f o r c o m p a t i b i l i t y o f t h e d i m e n s i o n s o f t h e m a t r i c e s d e f i n i n g
5 % t h e l i n e a r sy s t em ( a , b , c , d ) .
6 %
7 % Returns n = number o f s ys t e m s t a t e s ,
8 % r = number o f sy s te m i n p u t s ,
9 % m = number o f s y st e m o u t p u t s .
10 %
11 % Returns n = r = m = 1 i f t h e s y s te m i s n o t c o m p a t i b l e .
12
13 % A. S . Hodel <s c o t t e @ e n g . auburn . edu>
14
15 i f ( nargin = 4)
16 error ( usage : abcddim (a , b , c , d ) );
17 end
18
19 n = -1; r = -1; m = -1;
20
21 [ am , an ] = s i z e ( a );
22 i f ( am = an ) , error ( abcddim : a is not square ); end
23
24 [ bm , bn ] = s i z e ( b );
25 i f ( bm = am ) , error ( abcddim : a and b are not compatible ); end
26
27 [ cm , cn ] = s i z e ( c );
28 i f ( cn = an ) , error ( abcddim : a and c are not compatible ); end
29
30 [ dm , dn ] = s i z e ( d );
31 i f ( cm = dm ) , error ( abcddim : c and d are not compatible ); end
32 i f ( bn = dn ) , error ( abcddim : b and d are not compatible ); end
33
34 n = an ;
35 r = bn ;
36 m = cm ;
37
38 % abcddim .m

CC BY-NC-ND H.P. Gavin


16 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

damp.m http://www.duke.edu/hpgavin/damp.m
1 function [ wnout , z ] = damp (a , delta_t )
2 % DAMP N a t u r a l f r e q u e n c y and damping f a c t o r f o r c o n t i n u o u s s y s t e m s .
3 % [Wn, Z ] = DAMP(A) r e t u r n s v e c t o r s Wn and Z c o n t a i n i n g t h e
4 % n a t u r a l f r e q u e n c i e s and damping f a c t o r s o f A. The v a r i a b l e A
5 % can be i n one o f s e v e r a l f o r m a t s :
6 %
7 % 1) I f A i s s q u a r e , i t i s assumed t o be t h e s t a t e s p a c e
8 % A m a t r i x .
9 % 2) I f A i s a row v e c t o r , i t i s assumed t o be a v e c t o r o f
10 % t h e p o l y n o m i a l c o e f f i c i e n t s from a t r a n s f e r f u n c t i o n .
11 % 3) I f A i s a column v e c t o r , i t i s assumed t o c o n t a i n
12 % root locations .
13 %
14 % When i n v o k e d w i t h o u t l e f t hand arguments DAMP p r i n t s t h e
15 % e i g e n v a l u e s w i t h t h e i r n a t u r a l f r e q u e n c y and damping f a c t o r i n a
16 % t a b u l a r f o r m a t on t h e s c r e e n .
17
18 [m , n ] = s i z e ( a );
19
20 i f (n <1 || m <1) , wnout =0; z =0; return ; end
21
22 i f ( m == n )
23 r = e ig ( a );
24 e l s e i f ( m == 1)
25 r = ( roots ( a ));
26 e l s e i f ( n == 1)
27 r = a;
28 else
29 error ( Must be a vector or a square matrix . );
30 end
31
32 i f ( nargin == 2 ) , r = log ( r )/ delta_t ; end % d i s c r e t e time s ys t em
33
34 f o r k = 1: n
35 wn ( k ) = abs( r ( k ));
36 z(k) = - ( r e a l ( r ( k )) - 2* eps) / ( wn ( k ) + 2* eps );
37 end
38
39 [ wns , idx ] = sort (abs( wn )); % s o r t by i n c r e a s i n g n a t u r a l f r e q u e n c y
40 wn = wn ( idx );
41 z = z ( idx );
42 r = r ( idx );
43 wd = wn .* sqrt ( abs ( z .2 - 1 ) );
44
45 i f nargout == 0 % D i s p l a y r e s u l t s on t h e s c r e e n .
46 f p r i n t f ( \ n );
47 fprintf ( Natural Damped \ n );
48 fprintf ( Frequency Frequency Eigenvalue \ n );
49 fprintf ( ( cyc / sec ) Damping ( cyc / sec ) real imag \ n );
50 fprintf ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\ n );
51
52 f o r idx = 1:1: n
53 fprintf ( %10.5 f %10.5 f %10.5 f %10.5 f %10.5 f \ n , wn ( idx )/(2* pi ) , z ( idx ) , wd ( idx )/(2* p
54 end
55
56 return % S u p p r e s s o u t p u t
57 end
58 wnout = wn ;
59
60 % DAMP

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 17

mybode.m http://www.duke.edu/hpgavin/mybode.m
1 function [ mag , pha ] = mybode (a ,b ,c ,d , iu ,w ,axes , figno , leg , tol )
2 % [ mag , pha ] = mybode ( a , b , c , d , iu , w , axes , f i g n o , l e g , t o l )
3 % p l o t s t h e magnitude and p h a s e o f t h e
4 % s t e a d y s t a t e harmonic r e p o n s e o f a c o n t i n u o u s time l i n e a r dynamic sy s te m .
5 % where :
6 % a , b , c , d a r e t h e s t a n d a r d s t a t e s p a c e m a t r i c e s o f a dynamic sy s te m
7 % i u i s t h e s e l e c t e d i n p u t ( column o f B) ( d e f a u l t : i u = 1)
8 % w is a vector of frequencies ( d e f a u l t : w = l o g s p a c e ( 2 ,2 ,200)2 p i
9 % a x i s i s e i t h e r x , y , n , or b t o i n d i d a t e wich a x e s s h o u l d be l o g s c a l e d . . .
10 % x , y , n e i t h e r , or b o t h . The d e f a u l t i s b o t h . The ya x i s f o r t h e p h a s e p l o t
11 % i s a l w a y s l i n e a r l y s c a l e d .
12 % mag and pha a r e t h e magnitude and p h a s e o f t h e f r e q u e n c y r e s p o n s e f c t n
13
14 % Henri Gavin , Dept . C i v i l E n g i n e e r i n g , Duke U n i v e r s i t y , h e n r i . gavin@duke . edu
15
16 % Krajnik , Eduard , A s i m p l e and r e l i a b l e p h a s e unwrapping a l g o r i t h m ,
17 % h t t p : / /www. mathnet . or . k r / mathnet / p a p e r f i l e / Czech / Eduard / p h a s e . ps
18
19 [n ,m , p ] = abcddim (a ,b ,c , d ); % check f o r c o m p a t i b i l e dimensions
20
21 if ( nargin < 10) tol = 1e -16; end % default rcond l e v e l
22 if ( nargin < 7) axes = b ; end % default plot formatting
23 if ( nargin < 6) w = logspace ( -2 ,2 ,200)*2* pi ; end % d e f a u l t frequency axis
24 if ( nargin < 5) iu = 1; end % default input
25
26 nw = length ( w );
27 biu = b (: , iu );
28 diu = d (: , iu );
29
30 I = sqrt ( -1.0);
31
32 %warning o f f
33
34 g = zeros ( nw , p ); % a l l o c a t e memory f o r t h e f r e q u e n c y r e s p o n s e f u n c t i o n , g
35
36 % compute t h e f r e q u e n c y r e s p o n s e f u n c t i o n , g
37 f o r j =1: nw
38 % g ( j , : ) = [ c ( (w( j ) I e y e ( n)a ) \ b i u ) + d i u ] ;
39 [u ,s , v ] = svd( w ( j )* I *eye( n ) - a ); % s i n g u l a r v a l u e decomp . o f A
40 idx = max( find ( diag ( s ) > s (1 ,1)* tol ) );
41 char_eq = v (: ,1: idx ) * inv ( s (1: idx ,1: idx )) * u (: ,1: idx ) ;
42 g (j ,:) = [ c * char_eq * biu + diu ] ;
43 end
44
45 mag = abs( g );
46 pha = zeros ( nw , p );
47 pha (1 ,:) = -atan2(imag( g (1 ,:)) , r e a l ( g (1 ,:))); % ve s i g n !
48 pha (2: nw ,:) = ones( nw -1 ,1)* pha (1 ,:) - cumtrapz ( angle ( g (2: nw ,:)./ g (1: nw -1 ,:)));
49
50 %pha = unwrap(atan2 ( imag ( g ) , r e a l ( g ) ) ) ; % ve s i g n !
51
52 i f (nargout < 2 ) % s e t up t h e p l o t s
53
54 i f ( nargin >= 8) , f i g u r e ( figno ); e l s e f i g u r e (13); end
55 clf
56 subplot (211)
57 i f ( axes == x )
58 semilogx ( w /2/ pi , mag ); % p l o t t h e magnitude r e s p o n s e
59 e l s e i f ( axes == y )
60 semilogy ( w /2/ pi , mag ); % p l o t t h e magnitude r e s p o n s e

CC BY-NC-ND H.P. Gavin


18 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

61 e l s e i f ( axes == n )
62 plot ( w /2/ pi , mag ); % p l o t t h e magnitude r e s p o n s e
63 else
64 log log ( w /2/ pi , mag ); % p l o t t h e magnitude r e s p o n s e
65 end
66 i f ( nargin >= 9) , legend ( leg ); end
67
68 axis ([ min( w )/2/ pi , max( w )/2/ pi , min(min( mag )) , max(max( mag )) ]);
69 ylabel ( magnitude );
70 grid on
71
72 subplot (212)
73 i f ( axes == n || axes == y )
74 plot ( w /(2* pi ) , pha *180/ pi ); % p l o t the phase
75 else
76 semilogx ( w /(2* pi ) , pha *180/ pi ); % p l o t the phase
77 end
78 i f ( nargin >= 9) , legend ( leg ); end
79 pha_min = f l o o r (min(min( pha *180/ pi ))/90)*90;
80 pha_max = c e i l (max(max( pha *180/ pi ))/90)*90;
81 set (gca , ytick , [ pha_min : 90 : pha_max ])
82 axis ([ min( w )/2/ pi max( w )/2/ pi pha_min pha_max ]);
83 xlabel ( frequency ( Hertz ) )
84 ylabel ( phase ( degrees ) )
85 grid on
86
87 end
88 end
89
90 % MYBODE

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 19

11 Numerical Example: a spring-mass-damper oscillator

For the single degree of freedom oscillator of Section 2, lets say m = 2 ton,
c = 1.4 N/mm/s, k = 6.8 N/mm, do = 5.5 mm and vo = 2.1 mm/s. Note
that these units are consisent. (1 N)=(1 kg)(1 m/s2 )=(1 ton)(1 mm/s2 )

For these values, the linear time invariant system description of equations (7)
and (8) become

0 1 0 5.5
x(t) = x(t) + u(t) , x(0) = (38)
3.4 0.7 0.5 2.1

6.8 1.4 0
y(t) = x(t) + u(t) (39)
3.4 0.7 0.5

1. What are the natural frequencies and damping ratios of this system?

>> A = [ 0 1 ; -3.4 -0.7 ] % the dynamics matrix

A =
0.00000 1.00000
-3.40000 -0.70000

>> eig(A) % eigenvalues of the dynamics matrix

ans =
-0.3500 + 1.8104i
-0.3500 - 1.8104i

>> wn = abs(eig(A)) % absolute values of the eigs of A are omega_n

wn =
1.8439
1.8439

>> z = -real(eig(A)) ./ wn % ratio of real eig(A) to omega_n is damping ratio

z =
0.18981
0.18981

CC BY-NC-ND H.P. Gavin


20 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

>> wd = imag(eig(A)) % imaginary parts of the eigs of A are omega_d

wd =
1.8104
-1.8104

q
So, the natural frequency is 1.84 rad/s (the same as k/m), the damping

ratios is 19% (the same as c/ q 4mk), and the damped natural frequency
is 1.81 rad/s (the same as n | 2 1|).
These calculations can be done in one step with the m-file damp.m

>> damp(A)

Natural Damped
Frequency Frequency Eigenvalue
(cyc/sec) Damping (cyc/sec) real imag
-----------------------------------------------------
0.29347 0.18981 0.28813 -0.35000 1.81039
0.29347 0.18981 0.28813 -0.35000 -1.81039

2. What is the free response of this system to the specified initial conditions
xo ?

>> dt = 0.01; % time step value, sec


>> n = 1000; % number of time steps
>> t = [0:n-1]*dt; % time values, starting at t=0
>> xo = [ 5.5 ; 2.1]; % initial state (mm, mm/s)
>> C = [ 6.8 1.4 ; -3.4 -0.7 ]; % output matrix
>> y = zeros(2,n); % initialize outputs
>> for k=1:n
> y(:,k) = C*expm(A*t(k))*xo;
> end
>> plot(t,y)
>> legend(foundation force, N, mass acceleration, mm/s2)
>> xlabel(time, s)
>> ylabel(outputs, y_1 and y_2)

The free response is plotted in figure 1.

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 21

foundation force, N
40 mass acceleration, mm/s2

30

20
outputs, y1 and y2

10

-10

-20

0 2 4 6 8 10
time, s

Figure 1. Free response of the linear time invariant system given in equations (38) and (39).

3. What is the response of this system to a unit impuse, u(t) = (t)?


>> B = [ 0 ; 0.5 ]; % input matrix
>> v = 1;
>> h = zeros(2,n); % initialize unit impulse responses
>> for k=1:n
> h(:,k) = C*expm(A*t(k))*B*v;
> end
>> plot(t,h)
>> legend(foundation force, N, mass acceleration, mm/s2)
>> xlabel(time, s)
>> ylabel(unit impuse responses, h_1(t) and y_2(t))

The unit impuse response is plotted in figure 2.


4. What is the response of this system to external forcing u(t) = 50 cos(t)?
>> D = [ 0 ; 0.5 ]; % feedthrough matrix
>> u = 50 * cos(pi*t); % external forcing
>> y = lsym(A,B,C,D,u,t,xo); % use the "lsym" command
>> plot(t,y)
>> legend(foundation force, N, mass acceleration, mm/s2)
>> xlabel(time, s)
>> ylabel(forced harmonic responses, y_1(t) and y_2(t))

CC BY-NC-ND H.P. Gavin


22 CEE 541. Structural Dynamics Duke University Fall 2014 H.P. Gavin

1.5 foundation force, N


mass acceleration, mm/s2

unit impuse responses, h1(t) and h2(t)


1

0.5

-0.5

-1
0 2 4 6 8 10
time, s

Figure 2. Unit impulse response of the linear time invariant system given in equations (38) and
(39).

The forced harmonic response is plotted in figure 3.


5. What is the frequency response function from u(t) to y(t) for this system?

>> w = 2*pi*logspace(-1,0,100); % frequency axis data


>> bode(A,B,C,D,1,w);

The magnitude and phase of the steady-state forced harmonic response


is plotted in figure 4. Note how the magnitude and phase of the fre-
quency response shown in figure 4 can be used to predict the steady
steate response of the system to a forcing of u = 10 cos(t). (The forcing
frequency is 0.5 Hertz).

This is a fairly simple example. Nevertheless, by simply changing the def-


initions of the system matrices, A, B, C, and D, and of the input forcing
u(t), any linear time invariant system may be analyzed using the same sets
of Matlab commands.

CC BY-NC-ND H.P. Gavin


Linear Time Invariant Systems 23

60
40

input forcing
20
0
-20
-40
-60
0 2 4 6 8 10
time, s
60
responses, y1(t) and y2(t)

40
20
0
-20
-40
-60 foundation force, N
mass acceleration, mm/s2
-80
0 2 4 6 8 10
time, s

Figure 3. Forced response of the linear time invariant system given in equations (38) and (39).

100
magnitude

-1
10

100

180
phase (degrees)

90

-90

-180
100
frequency (Hertz)

Figure 4. Frequency response of the linear time invariant system given in equations (38) and
(39).

CC BY-NC-ND H.P. Gavin

Das könnte Ihnen auch gefallen