实验二控制系统的稳定性、能控性和能观测性分析ExperimentIIAnalysisofStability,ControllabilityandObservabilityby MATLABLExperimentalPurpose1. Analyzing the stability of the LTI system by the 2nd Lyapunov method2.Determining the controllability and observability of a control system.3.Obtaining the controllablecanonical formand observable canonical formby thestate transformation.4. Getting a minimal realization of the LTI system5.Placing the poles by state feedback controlII.ExperimentalContent2.1Consider the state space description of a LTI system is[1 -3.54.5[0.5]X=2-4.54.50.51.5[ 0.5]-2.5y=[1 0 ]xDetermine the stability by the Lyapunov 2nd Method.close allclear all% The system matrix of the systemA-[1 -3.5 4.5;2 -4.5 4.5;-1 1.5 -2.5];n=length(A);% determining the equilibrium point of the systemif(rank(A)==n)disp('the system is the only equilibrium point of the system.')
实验二 控制系统的稳定性、能控性和能观测性分析 Experiment II Analysis of Stability, Controllability and Observability by MATLAB I. Experimental Purpose 1. Analyzing the stability of the LTI system by the 2 nd Lyapunov method. 2. Determining the controllability and observability of a control system. 3. Obtaining the controllable canonical form and observable canonical form by the state transformation. 4. Getting a minimal realization of the LTI system. 5. Placing the poles by state feedback control. II. Experimental Content 2.1 Consider the state space description of a LTI system is y X X X u 1 0 1 0.5 0.5 0.5 1 1.5 2.5 2 4.5 4.5 1 3.5 4.5 = − − − + − − − − = Determine the stability by the Lyapunov 2nd Method. close all clear all % The system matrix of the system A=[1 -3.5 4.5;2 -4.5 4.5;-1 1.5 -2.5]; n=length(A); % determining the equilibrium point of the system. if(rank(A)==n) disp('the system is the only equilibrium point of the system.');
elsedisp(theoriginisanequilibriumpointofthesystem.):end% Q=IQ=eye(n,n);% Getting the solution matrix P of Lyapunov equation A'P+PA=-QP=lyap(transpose(A),Q);% X=lyap(A,Q) solves the Lyapunov equation AP+PAT=-Q% Calculating the principle minor determinant of the matrix P and determining thedefinitenessofPflag=0,for i=1.:nif(det(P(1:i, 1:i)<=0)flag=1;endend% Determining the stability of the systemIf flag=-1disp( the origin is unstable')elseif(rank(A)==n)disp( the origin system is globally asymptotically stable.);elsedisp(theorigin systemislocally asymptoticallystable'),endend
else disp('the origin is an equilibrium point of the system.'); end % Q=I Q=eye(n,n); % Getting the solution matrix P of Lyapunov equation T A P PA Q + = − . P=lyap(transpose(A),Q); % X = lyap(A,Q) solves the Lyapunov equation T AP PA Q + = − % Calculating the principle minor determinant of the matrix P and determining the definiteness of P. flag=0; for i=1:n if(det(P(1:i,1:i))<=0) flag=1; end end % Determining the stability of the system. If flag==1 disp(' the origin is unstable'); else if(rank(A)==n) disp(' the origin system is globally asymptotically stable.'); else disp(' the origin system is locally asymptotically stable '); end end
2.2Consider the state space description of a LTI system is20X=3 -1 1[0 20y=[0 0 1]x2.2.1 Calculating the controllability matrix and determining the controllability ofthe system.A=[1 2 0;3 -1 1;0 2 0]; B=[2;1;1]; C=[0 0 1]; D=[0];Qc=ctrb(A,B);nc=size(Qc,1);if(rank(Qc)-=nc)disp(' the system is completely controllable.);elsedisp(the system is not completely controllable.);end2.2.2Transformthestate spacedescription intothecontrollablecanonicalform:cp=poly(A);P=[A^2*B,A*B,B)*[cp(1),0,0;cp(2),cp(1),0; cp(3), cp(2),cp(1))[Ac,Bc,Cc,Dc]=ss2ss(A,B,C,D,inv(P))2.3Considerthestatespacedescriptionof aLTI system is[1021L1X101-2 [y=[0 1 1]x
2.2 Consider the state space description of a LTI system is 1 2 0 2 3 1 1 1 0 2 0 1 0 0 1 X X u y X = − + = 2.2.1 Calculating the controllability matrix and determining the controllability of the system. A=[1 2 0;3 -1 1;0 2 0]; B=[2;1;1]; C=[0 0 1]; D=[0]; Qc=ctrb(A,B); nc=size(Qc,1); if(rank(Qc)==nc) disp(' the system is completely controllable.'); else disp(' the system is not completely controllable.'); end 2.2.2 Transform the state space description into the controllable canonical form: cp=poly(A); P=[A^2*B,A*B,B]*[cp(1),0,0;cp(2),cp(1),0; cp(3), cp(2),cp(1)]; [Ac,Bc,Cc,Dc]=ss2ss(A,B,C,D,inv(P)) 2.3 Consider the state space description of a LTI system is 1 0 2 1 2 1 1 2 1 0 2 1 0 1 1 X X u y X = + − =
2.3.1Calculating the observability matrix and determining the observability of thesystem.A=[1 0 2 ;2 1 1;1 0 -2]; B=[1;2;1]; C=[0 1 1]; D=[0];Qo=obsv(A,C);no=size(Qo,2);if(rank(Qo)==no)disp(the system is completely observable.);elsedisp(the system is not completely observable.);end2.3.2 Transform the state space description into the observable canonical form:Transform the state space description into the observable canonical form:cp=poly(A);T=[ cp(1), cp(2), cp(3);0, cp(1),cp(2);0,0, cp(1))*[C*A^2;C*A;C];[Ao,Bo,Co,Do]=ss2ss(A,B,C,D,T)%不推荐使用[A1,B1,C1,D1]=canon(A,B,C,D,companion')2.4Consider the state space description of a LTI system is[-1010071000-101X=00100000Loolx00y=[12.4.1 Getting a minimal realization of the LTI system.A=[-10100;0-1000;0010;0001];
2.3.1 Calculating the observability matrix and determining the observability of the system. A=[1 0 2 ;2 1 1;1 0 -2]; B=[1;2;1]; C=[0 1 1]; D=[0]; Qo=obsv(A,C); no=size(Qo,2); if(rank(Qo)==no) disp(' the system is completely observable.'); else disp(' the system is not completely observable.'); end 2.3.2 Transform the state space description into the observable canonical form: Transform the state space description into the observable canonical form: cp=poly(A); T=[ cp(1), cp(2), cp(3);0, cp(1),cp(2);0,0, cp(1)]*[C*A^2;C*A;C]; [Ao,Bo,Co,Do]=ss2ss(A,B,C,D,T) %不推荐使用 [A1,B1,C1,D1]=canon(A,B,C,D,'companion') 2.4 Consider the state space description of a LTI system is y X X X u 1 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 10 0 0 10 1 0 0 = + − − = 2.4.1 Getting a minimal realization of the LTI system. A=[-10 1 0 0;0 -10 0 0;0 0 1 0;0 0 0 1];
B=[1;1;0;0]; C=[1 0 0 0]; D=[0];[Am,Bm,Cm,Dm]=minreal(A,B,C,D);2.4.2Comparingthetransferfunction of the system with its minimal realization[z1,p1,k1]=ss2zp(A,B,C,D);sys1=zpk(zl,p1,k1)[z2,p2,k2]=ss2zp(Am,Bm,Cm,Dm);sys2=zpk(z2,p2,k2)%Therealization isa minimal realizationiff itis completely controllable andcompletely observable%TheLTTSISOsystemiscompletelycontrollableandobservableiffitstransfenfunctiondoesnothavepole-zerocancellation2.5Consider the LTI system described byTo00[]X =-601ouX+LoLo1-12y=[0 0 1]xDesign the state feedback gain vectorKthat assigns the set of closed-loopeigenvalues as (-2,-1+j, -1-j }.% The original systemA=[0 0 0;1 -6 0;0 1 -12]; b=[1;0;0]; c=[0 0 1]; d=0;G=ss(A,b,c,d)%The poles of the initial systemeig(A)%Expected poles of the systemP=[-1+i,-1-i,-2]; % The components of vector P are the expected poles
B=[1;1;0;0]; C=[1 0 0 0]; D=[0]; [Am,Bm,Cm,Dm]=minreal(A,B,C,D); 2.4.2 Comparing the transfer function of the system with its minimal realization [z1,p1,k1]=ss2zp(A,B,C,D); sys1=zpk(z1,p1,k1) [z2,p2,k2]=ss2zp(Am,Bm,Cm,Dm); sys2=zpk(z2,p2,k2) % The realization is a minimal realization iff it is completely controllable and completely observable. % The LTI SISO system is completely controllable and observable iff its transfer function does not have pole-zero cancellation. 2.5 Consider the LTI system described by y X X X u 0 0 1 0 0 1 0 1 12 1 6 0 0 0 0 = + − = − Design the state feedback gain vector K that assigns the set of closed-loop eigenvalues as − + − 2, 1 , 1 - j - j . % The original system A=[0 0 0;1 -6 0;0 1 -12]; b=[1;0;0]; c=[0 0 1]; d=0; G=ss(A,b,c,d) %The poles of the initial system eig(A) % Expected poles of the system P=[-1+i,-1-i,-2]; % The components of vector P are the expected poles