Beruflich Dokumente
Kultur Dokumente
Henri P. Gavin
Fall 2014
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.
Systems described by
(m2 + c + k)r = 0 .
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;
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),
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
An efficient method for computing y(t) for a arbitrary inputs u(t) is provided
in the last sections of this document.
If A = AT then eA > 0.
[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
= 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
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).
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
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.
X = [x1 x2 xn ] .
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)
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 ,
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 ,
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.
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,
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
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
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
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
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
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
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
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
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.00000 1.00000
-3.40000 -0.70000
ans =
-0.3500 + 1.8104i
-0.3500 - 1.8104i
wn =
1.8439
1.8439
z =
0.18981
0.18981
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 ?
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).
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).
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).