THE UNIVERSITY OF TEXAS AT SAN ANTONIO EE 543 LINEAR SYSTEMS AND CONTROL H O M E W O R K # 4 Sebasian A. Nugroho Ocober 5, 27 The objecive of his homework is o es your undersanding of he conen of Module 4. Due dae of he homework is: Thursday, Ocober 5h @ :59pm.. Consider he following ime-varying sysem: (a) Find he sae ransiion marix. ẋ() + + x(). (b) Now assume ha he sysem sars from an unknown x() Also, assume ha x 2 ( 4). Given his, find x 2 (). x (), where x x 2 () (). (c) Afer obaining x 2 () and given x (), find a general from of x() saring x() as iniial condiions. (d) Wha happens o x () and x 2 () as? Answer: (a) Realize ha where A() + + + A 2 A A β ()A,, hence, A is idempoen. Now, we need o evaluae he following inegral β (τ) dτ + dτ ( + dτ ln + ). + The sae ransiion marix now can be formulaed as where γ ln ( + + β Φ(, ) e (τ)a dτ ln e ) and Φ(, ) e γa (γa ) i i! i I + γa + γ2 A 2! ( + + I + γa + γ2 A 2 2! + γ3 A 3! ) A e γa, +... + γ3 A 3 3! I + A ( + γ + γ2 2! + γ3 3! +... ) I + A (e γ ) I + A ( + + ) ( + ) + + + + + +. +...
(b) We know ha he soluion is given as x() Φ(, )x( ). Now, for 4 and wih x () and x 2 (4), we have x x (4) 4+ () x 2 (4) 4+ x 2 () x (4) 5 4 5 x 2 () x (4) 5 4 5 + x. 2() We finally ge x 2 () 5. (c) The general form of x() is (d) As, we ge lim x x () + x 2 () + 5 x () x 2 () x () x 2 () + + 6 5 lim x + lim x ( + 6 5 2. The STM of ẋ() A()x() is given as follows: ( ) + φ(, ) e 2 2 ln +. ) 5 6. (a) Given any STM, how can you obain A() back? Prove ha A() φ(, ) for any LTV sysem. (b) For he STM given in his problem, obain A(). (c) Find φ (, ) Answer: (a) Proof: Φ(, ) d d Φ(, ) d d e A(τ) dτ ( d I + A(τ) dτ + ( ) 2 A(τ) dτ + ( ) 3 A(τ) dτ +...) d 2! 3! d ( ) d A(τ) dτ + A(τ) dτ A(τ) dτ + ( ) 2 d A(τ) dτ A(τ) dτ +... d d 2! d ( ) A() + A(τ) dτ A() + ( ) 2 A(τ) dτ A() + ( ) 3 A(τ) dτ A() +..., 2! 3! since A() commues wih is inegral, hen ( ) Φ(, ) A() + A() A(τ) dτ + ( ) 2 2! A() A(τ) dτ + ( ) 3 3! A() A(τ) dτ +... ( A() I + A(τ) dτ + ( ) 2 A(τ) dτ + ( ) 3 A(τ) dτ +...) 2! 3! A(τ) dτ A()e A()Φ(, ), 2
seing, and knowing he fac ha Φ(, ) I, we ge Φ(, ) A()Φ(, ) A() (b) Since ( ) + φ(, ) e 2 2 ln +, hen he derivaive of φ(, ) is ( ) + φ(, ) d d Φ(, ) 2e 2 2 ln + ( ) + 2e2 2 2e 2 2 ln + e2 2 + +. 2e 2 2 + e 2 2 + Seing yields which implies φ(, ) 2 +, 2 A() 2 +. 2 (c) φ (, ) can be compued as 3. The following sysem φ (, ) φ(, ) ( ) e 2 2 ln + + ( ) e2 2 e 2 2 + ln +. e 2 2 ẋ() A()x() + e α2 () π u(). The STM for his sysem is given by: φ(, ) e α2 ( ) α 2 (). cos(π) cos(π ) (a) Compue A(). (b) Deermine he inverse of he STM. (c) Find x() if x( ) and u(). Answer: 3
(a) The derivaive of φ(, ) can be compued as Φ(, ) d d φ(, ) 2α() α()e α2 ( ) α 2 () 2α() α()e α2 ( ) α 2 () (cos(π) cos(π )) + e α2 ( ) α 2 () (π sin(π)) 2α() α()e α2 ( ) α 2, () seing, hen we ge 2α() α() A() Φ(, ). π sin(π) 2α() α() (b) φ (, ) φ(, ) e α2 () α 2 ( ) cos(π ) cos(π) e α2 () α 2 ( ) e α2 () α 2 ( ) (cos(π ) cos(π)) e α2 () α 2. ( ) (c) The soluion is given as x() Φ(, )x( ) + Φ(, τ)b(τ)u(τ) dτ, for and x(), hen e x() α2 (τ) α 2 () e α2 (τ) α 2 () (cos(π) cos(πτ)) πe α2 () πe α2 () dτ (cos(π) cos(πτ)) πτe α2 () πτe α2 () cos(π) e α2 () sin(πτ)) πe α2 () πe α2 () cos(π) e α2 () sin(π) πe α2 () e α2 (). (π cos(π) sin(π)) e α2 (τ) α 2 () πe α 2 (τ) () dτ 4. Find he STM associaed wih sin() cos() β A() sin() cos(). sin() Answer: sin() cos() β A() sin() cos() sin() + cos() + β. sin() Now, he followings mus be compued sin(τ) dτ cos() + cos( ) cos(τ) dτ sin() sin( ) 4
β dτ β( ) and he exponenial marices Since A is ideniy, hen e cos()+cos( ) sin(τ)a e dτ e cos()+cos( ) I e cos()+cos(). e cos()+cos() Noice ha A 2 is nilpoen for k 3, hus cos(τ)a e 2 dτ I + A2 (sin() sin( )) + 2! A2 2 (sin() sin()) 2 + (sin() sin( )) + (sin() sin( )) 2 2! sin() sin( ) 2 (sin() sin( )) 2 sin() sin( ). Noice ha A 3 is nilpoen for k 2, hus e Because A, A 2, and A 3 commue, hen A(τ) dτ Φ(, ) e e βa 3 dτ I + A3 β( ) + β( ) β( ). sin(τ)a dτ e cos(τ)a 2 dτ e e cos()+cos() βa 3 dτ sin() sin( ) 2 (sin() sin( )) 2 sin() sin( ) β( ). 5. Consider he following dynamical sysem: A () A ẋ() 2 () x(). A 22 () (a) Derive his srucure for he STM: φ(, ) φ (, ) φ 2 (, ). φ 22 (, ) You should basically show ha φ ii (, ) A ii ()φ ii (, ), and hen show a explici form for φ 2 (, ). Hin: Remember ha φ(, ) A()φ(, ) and φ(, ) I. You should use ha o prove he following resul: φ 2 (, ) φ (, τ)a 2 (τ)φ 22 (τ, )dτ. 5
(b) Assume ha he dynamics for a sysem are given by: 2 ẋ() x() + u(). 2 Answer: Use he resuls you developed in par (a) o deermine x() giving ha he iniial condiions for he sysem are zero, and u(), wihou evaluaing his inegral φ(, τ)b(τ)u(τ)dτ. (a) Since φ(, ) A()φ(, ), hen φ (, ) φ 2 (, ) φ 22 (, ) φ(, ) A()φ(, ) A () A φ(, ) 2 () φ (, ) φ 2 (, ) A 22 () φ 22 (, ) A ()φ (, ) A ()φ 2 (, ) + A 2 ()φ 22 (, ) A 22 ()φ 22 (, ) From he above, i is apparen ha φ ii (, ) A ii ()φ ii (, ). Now, we need o show he explici form of φ 2 (, ). From he above, we also have Pre-muliply wih φ (, ) yields φ 2 (, ) A ()φ 2 (, ) + A 2 ()φ 22 (, ). φ (, ) φ 2 (, ) φ (, )A ()φ 2 (, ) φ (, )A 2 ()φ 22 (, ). Realize ha φ (, ) is equal o φ (, ) d d e ( d d A (τ) dτ I + A (τ) dτ + ( 2! ( d A d (τ) dτ + + ( ) 2 d A 2! (τ) dτ d ( A () A (τ) dτ 3! ( Hence, we have A (τ) dτ ( 3 A (τ) dτ) A ()... I + A (τ) dτ + 2! φ (, )A (). ) 2 A (τ) dτ + 3! ) d d A (τ) dτ +... A (τ) dτ. ( ) 3 A (τ) dτ) +... ) A () ( 2 A 2! (τ) dτ) A () ( ) 2 A (τ) dτ + ( ) 3 A 3! (τ) dτ) +... φ (, ) φ 2 (, ) + φ (, )φ 2 (, ) φ (, )A 2 ()φ 22 (, ) d d (φ (, )φ 2 (, )) φ (, )A 2 ()φ 22 (, ) d (φ (, τ)φ 2 (τ, )) φ (, )φ 2 (, ) I 6 φ (, τ)a 2 (τ)φ 22 (τ, ) dτ φ (, τ)a 2 (τ)φ 22 (τ, ) dτ. A ()
Pre-muliply wih φ (, ) yields φ 2 (, ) φ (, ) + φ (, τ)a 2 (τ)φ 22 (τ, ) dτ. This resul is slighly differen han he one in he problem. I will be equivalen if we have φ (, ). (b) The sae ransiion marix is φ 2 (, ) φ (, τ)a 2 (τ)φ 22 (τ, ) dτ 2τ dτ 2 2. Then for a sysem wih zero iniial condiion, x() 2 τ 2 dτ 2τ 2 2 τ 2τ 3 dτ 2τ 2 τ 2 2 τ4 τ 2 2 4 2 2 + 2 4 2 2. 6. Building on he heoreical resuls from Problem 5, find he STM for A() 2 2 2. 2 You should use he resul you proved in Problem 5: Answer: φ 2 (, ) φ (, τ)a 2 (τ)φ 22 (τ, )dτ. φ 2 (, ) φ (, τ)a 2 (τ)φ 22 (τ, )dτ 2 τ 2τ 2 dτ 2 2τ 2 τ 2 τ 2 2τ τ 2τ 2( ) 2 ( 2 2 ) 2 2 2( ). 2( ) 7. You are given he following sysem: a() b() c() ẋ() λ()i + a() b() c() x() + u(), a() b() c() where M() denoes he derivaive of he marix, i.e., derivaive of he individual enries of he marix. 7
(a) Assume ha a() + b() + c() for all. Find a simple expression for φ(, ). (b) Given ha he conrol inpu is u() 2e λ(), and ha x(2) Answer:, obain x(). (a) Realize ha a() b() c() A() λ()i + a() b() c() a() b() c() A () + A 2 (), where A () and A 2 () commue. To compue is sae ransiion marix, we need o evaluae he following exponenial marices and e λ() λ( ) A e (τ) dτ e λ() dτ I e λ() λ(), e λ() λ() A e 2 (τ) dτ I + A 2 (τ) dτ + ( ) 2 A 2 (τ) dτ + ( ) 3 A 2 (τ) dτ +.... 2! 3! For he laer, firs we need o compue a() A 2 (τ) dτ a( ) b() b( ) c() c( ) a() a( ) b() b( ) c() c( ). a() a( ) b() b( ) c() c( ) Since a() + b() + c(), hen a() A 2 (τ) dτ a( ) b() b( ) a() b() + a( ) + b( ) a() a( ) b() b( ) a() b() + a( ) + b( ). a() a( ) b() b( ) a() b() + a( ) + b( ) We know ha he above marix is nilpoen for k 2, hus A e 2 (τ) dτ I + A 2 (τ) dτ + a() a( ) b() b( ) a() b() + a( ) + b( ) a() a( ) + b() b( ) a() b() + a( ) + b( ). a() a( ) b() b( ) a() b() + a( ) + b( ) The sae ransiion marix can now be formulaed as A Φ(, ) e (τ) dτ e A 2 (τ) dτ e λ() λ() + a() a( ) b() b( ) a() b() + a( ) + b( ) a() a( ) + b() b( ) a() b() + a( ) + b( ). a() a( ) b() b( ) a() b() + a( ) + b( ) 8
(b) The soluion of he above sysem is compued as follows x() Φ(, )x() + Φ(, τ)b(τ)u(τ) dτ + a() a() b() b() a() b() + a() + b() e λ() λ() a() a() + b() b() a() b() + a() + b() x() a() a() b() b() a() b() + a() + b() + a() a(τ) b() b(τ) a() b() + a(τ) + b(τ) + e λ() λ(τ) a() a(τ) + b() b(τ) a() b() + a(τ) + b(τ) a() a(τ) b() b(τ) a() b() + a(τ) + b(τ) (2e λ(τ) ) dτ + a() a() b() b() a() b() + a() + b() e λ() λ() a() a() + b() b() a() b() + a() + b() x() a() a() b() b() a() b() + a() + b() + 2e λ() 2e λ() 2e λ() dτ + a() a() b() b() a() b() + a() + b() e λ() λ() a() a() + b() b() a() b() + a() + b() x() a() a() b() b() a() b() + a() + b() 2τe λ() + 2τe λ() 2τe λ() + a() a() b() b() a() b() + a() + b() e λ() λ() a() a() + b() b() a() b() + a() + b() x() a() a() b() b() a() b() + a() + b() 2e λ() + 2e λ(). 2e λ() Subsiuing 2 and x(2) yields + a(2) a() b(2) b() a(2) b(2) + a() + b() e λ(2) λ() a(2) a() + b(2) b() a(2) b(2) + a() + b() x () 4e λ(2) x 2 () + 4e λ(2) a(2) a() b(2) b() a(2) b(2) + a() + b() x 3 () 4e λ(2) ( + a(2) a())x () + (b(2) b())x 2 () + ( a(2) b(2) + a() + b())x 3 () + 4e λ() e λ(2) λ() (a(2) a())x () + ( + b(2) b())x 2 () + ( a(2) b(2) + a() + b())x 3 () + 4e λ() (a(2) a())x () + (b(2) b())x 2 () + ( a(2) b(2) + a() + b())x 3 () + 4e λ() From he above equaion, one can obain x() where such ha x () x 2 () x 3 () 4eλ() e λ(2) λ(), x() x () x 2 () x 3 () 4e λ() e λ(2) λ() 4e λ() e λ(2) λ() 4e λ() e λ(2) λ(). 9
8. Using MATLAB, generae a random LTI dynamical sysem of saes, 5 conrol inpus, and 3 oupus. Simulae he sysem given ha he inpus are square(), sin(), cos() and he iniial condiions for he sysem are idenically zero. Firs, simulae he sysem using he ode45 solver. Then, apply he wo discreizaion mehods we discussed in class wih variable sampling periods. For example rying sampling periods of T.,., and 5 seconds. Discuss he oucome ha you ge beween he accurae ODE solver and wo discreizaion mehods. Is he discreizaion always accurae? When does i fail (if i does)? Include your code, plos, and a horough analysis of he resuls. Answer: Here, a randomly-generaed sable sysem is used. The inpu is a combinaion of sine, cosine, and square waves. The oupu of he LTI sysem is depiced in Fig.. The firs DTI is obained by applying he forward Euler discreizaion mehod. Here, several sampling periods are sudied. The oupu of his DTI sysem is given in Fig. 2. The second DTI is derived using he exac discreizaion mehod. I s oupu is given in Fig. 3. From hese figures, i is apparen ha for all DTI sysems, he ones wih smalles sampling period, which is Ts. s, have oupus ha are similar o ha of he LTI sysem. As he sampling period increases, he DTI sysems fail o give he same oupus as he LTI sysem. This happens because he approximaion of he LTI sysem in discree-ime is worse. A Ts.5 s, he firs DTI sysem compleely fails, hence i gives unsable oupu rajecory, whereas he second DTI sysem sill gives sable oupu rajecory, even if he oupu is much differen compared o he LTI sysem. This shows he superioriy of he exac discreizaion mehod over he simpler Euler discreizaion mehod. The MATLAB code is given below. 8 6 4 2-2 -4-6 -8 2 4 6 8 2 4 6 8 2 Figure : Oupu rajecory of he LTI sysem. %% Sysem Iniializaion clear all close all %Figure index
2.7373 38 8 5 6 4 5 2.33-2 -5-4 - -6-5 -8 5 5 2-2 5 5 2 -.6766 2 3 4 Figure 2: Oupu rajecory of he DTI sysem discreized by forward Euler mehod. figidx ; %Size sys.n ; sys.m 5; sys.p 3; %Random number inerval l -4; u 4; %Creae random marix sys.a l + (u-l)*rand(sys.n,sys.n); sys.b l + (u-l)*rand(sys.n,sys.m); sys.c l + (u-l)*rand(sys.p,sys.n); %Ge a sable A for i :sys.n sys.a(i,i) -5 + (--(-5))*rand(,); %Save sysem save( sysem_daa.ma, sys ) %Iniial condiion x zeros(sys.n,); %% LTI Sysem
2 2 8 5 5 6 4 2-2 -4 5-5 - 5-5 - -6-5 -5-8 5 5 2-2 5 5 2-2 5 5 2 Figure 3: Oupu rajecory of he DTI sysem discreized by exac discreizaion mehod. %Inerval ff 2; period.; span :period:ff; %ODE, x ode45(@model, span, x,, sys); %Generae y y zeros(lengh(),sys.p); for i:lengh() x x(i,:) ; y(i,:) sys.c*x; figure(figidx); figidx figidx + ; fs 6; se(gcf, numberile, off, name, Norm ) plo(,y(:,), r,,y(:,2), g,,y(:,3), b,... LineWidh,3); ile( LTI Sysem, Inerpreer, laex ) grid on xlabel( $\exrm{time\,(seconds)}$, inerpreer, laex, FonName, Times New Roman, FonSize,f ylabel( $y()$, inerpreer, laex, FonName, Times New Roman, FonSize,fs); se(gca, FonName, Times New Roman, fonsize,fs); h leg( $y_()$, $y_2()$, $y_3()$, Locaion, norheas ); se(h, Inerpreer, laex ) se(h, Fonsize,fs) 2
se(gcf, color, w ); %% DTI Based On Forward Euler Discreizaion Mehod, Ts. s %Time sampling Ts.; %Discreize Ad eye(sys.n)+sys.a*ts; Bd sys.b*ts; Cd sys.c; %Inerval ff 2; period.; span :period:ff; %Conrol inpu u ; for i:lengh(span) u sin(span(:,i)); cos(span(:,i)); square(span(:,i)); cos(span(:,i)); sin(span(:,i)); u u; u ; %sar simulaion x ; y ; xk x; for i:lengh(span) xkk Ad*xk + Bd*u(i,:) ; yk Cd*xk; x x; xkk ; y y; yk ; xk xkk; figure(figidx); %figidx figidx+; fs 6; se(gcf, numberile, off, name, Norm ) subplo(,3,); plo(span,y(:,), r,span,y(:,2), g,span,y(:,3), b,... LineWidh,3); ile({ DTI Sysem wih Euler Discreizaion Mehod, Ts. s }, Inerpreer, laex ) grid on xlabel( $\exrm{time\,(seconds)}$, inerpreer, laex, FonName, Times New Roman, FonSize,f ylabel( $y(k)$, inerpreer, laex, FonName, Times New Roman, FonSize,fs); se(gca, FonName, Times New Roman, fonsize,fs); h leg( $y_(k)$, $y_2(k)$, $y_3(k)$, Locaion, norheas ); se(h, Inerpreer, laex ) se(h, Fonsize,fs) se(gcf, color, w ); %% DTI Based On Forward Euler Discreizaion Mehod, Ts. s %Time sampling 3
Ts.; %Discreize Ad eye(sys.n)+sys.a*ts; Bd sys.b*ts; Cd sys.c; %Inerval ff 2; period.; span :period:ff; %Conrol inpu u ; for i:lengh(span) u sin(span(:,i)); cos(span(:,i)); square(span(:,i)); cos(span(:,i)); sin(span(:,i)); u u; u ; %sar simulaion x ; y ; xk x; for i:lengh(span) xkk Ad*xk + Bd*u(i,:) ; yk Cd*xk; x x; xkk ; y y; yk ; xk xkk; figure(figidx); %figidx figidx + ; fs 6; se(gcf, numberile, off, name, Norm ) subplo(,3,2); plo(span,y(:,), r,span,y(:,2), g,span,y(:,3), b,... LineWidh,3); ile({ Ts. s }, Inerpreer, laex ) grid on xlabel( $\exrm{time\,(seconds)}$, inerpreer, laex, FonName, Times New Roman, FonSize,f ylabel( $y(k)$, inerpreer, laex, FonName, Times New Roman, FonSize,fs); se(gca, FonName, Times New Roman, fonsize,fs); h leg( $y_(k)$, $y_2(k)$, $y_3(k)$, Locaion, norheas ); se(h, Inerpreer, laex ) se(h, Fonsize,fs) se(gcf, color, w ); %% DTI Based On Forward Euler Discreizaion Mehod, Ts.5 s %Time sampling Ts.5; %Discreize Ad eye(sys.n)+sys.a*ts; 4
Bd sys.b*ts; Cd sys.c; %Inerval ff 2; period.; span :period:ff; %Conrol inpu u ; for i:lengh(span) u sin(span(:,i)); cos(span(:,i)); square(span(:,i)); cos(span(:,i)); sin(span(:,i)); u u; u ; %sar simulaion x ; y ; xk x; for i:lengh(span) xkk Ad*xk + Bd*u(i,:) ; yk Cd*xk; x x; xkk ; y y; yk ; xk xkk; figure(figidx); figidx figidx + ; fs 6; se(gcf, numberile, off, name, Norm ) subplo(,3,3); plo(span,y(:,), r,span,y(:,2), g,span,y(:,3), b,... LineWidh,3); ile({ Ts.5 s }, Inerpreer, laex ) grid on xlabel( $\exrm{time\,(seconds)}$, inerpreer, laex, FonName, Times New Roman, FonSize,f ylabel( $y(k)$, inerpreer, laex, FonName, Times New Roman, FonSize,fs); se(gca, FonName, Times New Roman, fonsize,fs); h leg( $y_(k)$, $y_2(k)$, $y_3(k)$, Locaion, norheas ); se(h, Inerpreer, laex ) se(h, Fonsize,fs) se(gcf, color, w ); %% DTI Based On Exac Discreizaion Mehod, Ts. s %Time sampling Ts.; %Discreize Ad expm(sys.a*ts); Bd inv(sys.a)*(ad-eye(sys.n))*sys.b; Cd sys.c; %Inerval ff 2; 5
period.; span :period:ff; %Conrol inpu u ; for i:lengh(span) u sin(span(:,i)); cos(span(:,i)); square(span(:,i)); cos(span(:,i)); sin(span(:,i)); u u; u ; %sar simulaion x ; y ; xk x; for i:lengh(span) xkk Ad*xk + Bd*u(i,:) ; yk Cd*xk; x x; xkk ; y y; yk ; xk xkk; figure(figidx); %figidx figidx + ; fs 6; se(gcf, numberile, off, name, Norm ) subplo(,3,); plo(span,y(:,), r,span,y(:,2), g,span,y(:,3), b,... LineWidh,3); ile({ DTI Sysem wih Exac Discreizaion Mehod, Ts. s }, Inerpreer, laex ) grid on xlabel( $\exrm{time\,(seconds)}$, inerpreer, laex, FonName, Times New Roman, FonSize,f ylabel( $y(k)$, inerpreer, laex, FonName, Times New Roman, FonSize,fs); se(gca, FonName, Times New Roman, fonsize,fs); h leg( $y_(k)$, $y_2(k)$, $y_3(k)$, Locaion, norheas ); se(h, Inerpreer, laex ) se(h, Fonsize,fs) se(gcf, color, w ); %% DTI Based On Exac Discreizaion Mehod, Ts. s %Time sampling Ts.; %Discreize Ad expm(sys.a*ts); Bd inv(sys.a)*(ad-eye(sys.n))*sys.b; Cd sys.c; %Inerval ff 2; period.; span :period:ff; %Conrol inpu u ; 6
for i:lengh(span) u sin(span(:,i)); cos(span(:,i)); square(span(:,i)); cos(span(:,i)); sin(span(:,i)); u u; u ; %sar simulaion x ; y ; xk x; for i:lengh(span) xkk Ad*xk + Bd*u(i,:) ; yk Cd*xk; x x; xkk ; y y; yk ; xk xkk; figure(figidx); %figidx figidx + ; fs 6; se(gcf, numberile, off, name, Norm ) subplo(,3,2); plo(span,y(:,), r,span,y(:,2), g,span,y(:,3), b,... LineWidh,3); ile({ Ts. s }, Inerpreer, laex ) grid on xlabel( $\exrm{time\,(seconds)}$, inerpreer, laex, FonName, Times New Roman, FonSize,f ylabel( $y(k)$, inerpreer, laex, FonName, Times New Roman, FonSize,fs); se(gca, FonName, Times New Roman, fonsize,fs); h leg( $y_(k)$, $y_2(k)$, $y_3(k)$, Locaion, norheas ); se(h, Inerpreer, laex ) se(h, Fonsize,fs) se(gcf, color, w ); %% DTI Based On Exac Discreizaion Mehod, Ts.5 s %Time sampling Ts.5; %Discreize Ad expm(sys.a*ts); Bd inv(sys.a)*(ad-eye(sys.n))*sys.b; Cd sys.c; %Inerval ff 2; period.; span :period:ff; %Conrol inpu u ; for i:lengh(span) u sin(span(:,i)); cos(span(:,i)); square(span(:,i)); cos(span(:,i)); sin(span(:,i)); u u; u ; 7
%sar simulaion x ; y ; xk x; for i:lengh(span) xkk Ad*xk + Bd*u(i,:) ; yk Cd*xk; x x; xkk ; y y; yk ; xk xkk; figure(figidx); figidx figidx + ; fs 6; se(gcf, numberile, off, name, Norm ) subplo(,3,3); plo(span,y(:,), r,span,y(:,2), g,span,y(:,3), b,... LineWidh,3); ile({ Ts.5 s }, Inerpreer, laex ) grid on xlabel( $\exrm{time\,(seconds)}$, inerpreer, laex, FonName, Times New Roman, FonSize,f ylabel( $y(k)$, inerpreer, laex, FonName, Times New Roman, FonSize,fs); se(gca, FonName, Times New Roman, fonsize,fs); h leg( $y_(k)$, $y_2(k)$, $y_3(k)$, Locaion, norheas ); se(h, Inerpreer, laex ) se(h, Fonsize,fs) se(gcf, color, w ); %% LTI Sysem Model %Sysem model funcion xdo model(, x, sys) %% % Conrol inpu u sin(); cos(); square(); cos(); sin(); % Sysem xdo sys.a*x + sys.b*u; 8