Code covered by the BSD License

# Descritor LTI and LPV Calculation Tool-Kit

01 Mar 2013

Algorithms for analysis, state estimation and fault detection for Descriptor LTI and LPV systems.

Demo2.m
% this example is based in the following paper
% Observer stimation of descritor system. THis example is based on
%IEEE  TRANSACTIONS  ON AUMMATIC  CONTROL, VOL.  40, NO.  7. JULY  I995
%Design of  Observers for Descriptor Systems
%M.  Darouach  and  M.  Boutayeb
%clear;

clc;
clear();
close();
disp('Simlation of a reduced order observer like Darouach 1995')
disp('Matrices of the descriptor system')
E=[1 0 0 0 ; 0 1 0 0; 0 0 0 0; 0 0 0 0]
A=[0 0 1 0 ; 1 0 0 0; -1 0 0 1; 0 1 1 1]
B=[0 0 0 -1]'
C=[0 1 0 0; 1 0 1 0; 0 0 1 0]
% % if the unkwon output is C2, then
disp('if the unkwon output is C2, then')
pause
C=C(3,:)

dsys=dsystem(E,A,B,C);
disp('Computing the gains of the reduced order observer')
pause

[Pi,L, H,M, F,Be1]=redobsv95(dsys)

disp('simulation of the system and the observer')
disp('Initial conditions')
Te=0.1;
x1(1)=0; x2(1)=0;x3(1)=0; x4(1)=0;
% set of intial conditions
xx(:,1)=[x1(1) x2(1) x3(1) x4(1)]'
y(:,1)=C*xx
% initial conditions for the observer

z=0
xe=[ 1 5 3 0]'% intial stimated states
ye(:,1)=C*xe % compute the initial output
t(1)=0;% initial time
u(1)=0;

% observer gains
% % if the system is observable then compute the restricted system equivalence systems by QR descomposition
disp('Simulation')

for k=1:50/Te
% Time counter
t(k+1)=t(k)+Te;
% input
if t(k)<7
u(k+1)=1;
else
u(k+1)=5;
end
%    % the differentials equations can be solved by runge-kuta of four order
x1=x1+Te*(x3);
x2=x2+Te*(x1);
x4=x1;
x3=-x2-x4+u(k);
xx(:,k+1)=[x1 x2 x3 x4]';
y(:,k+1)=C*xx(:,k+1); % system output
% Observer
yi=[-Be1*u(k);y(:,k)]; % auxiliar for compute the observer
%  Reduced order observer
% $z=Piz+Lyi+H*u$
% $\hat{x}=Mz+Fyi$
z(k+1)=z(k)+Te*(Pi*z(k)+L*yi+H*u(k)); %
xe(:,k+1)=M*z(k)+F*yi;

ye(:,k+1)=C*xe(:,k+1); % stimated output

% Generation of residuos
end

disp('PLOTS')
pause
figure(2);
cla();
plot(t,y',t,ye')
legend('output', 'stimated')