from Eigenstructure assignment based residual generation by Hafiz Bilal Ahmad
A collection of m-files and simulink models for the generation of robust residuals.

inv_pen_eig.m
% --------System Matrices---------%
A=[0 1 0 0;19.6 0 0 0;0 0 0 1;-9.8 0 0 0];
B=[0;-1;0;1];
C=eye(4);

%---------Disturbance Matrix----------%
E=[1;1;1;1];

%---------LQR design----------%
Q=[.25 0 0 0;0 1 0 0;0 0 4 0;0 0 0 1];
R=.0003;
[M l s]=lqr(A,B,Q,R);

%---------Eigen values and corresponding Eigenvectors-------%
[eigvec eigval]=eig(A);

%--Calculation of Eigenstucture assignment based Observer gain 'K'--%
Q1=[-4.4272*eye(4,4)-A' C'];
[S U V]=svd(Q1);
L1=V(:,5:8);
P1=L1(1:4,:);
T1=L1(5:8,:);
J1=[P1(1,:)+P1(4,:);P1(2,:)+P1(3,:)];
e1=inv(J1'*J1)*J1'*eigvec(2:3,1);
l1=P1*e1;
z1=T1*e1;
Q2=[-5*eye(4,4)-A' C'];
[S U V]=svd(Q2);
L2=V(:,5:8);
P2=L2(1:4,:);
T2=L2(5:8,:);
J2=[P2(1,:)+P2(4,:);P2(2,:)+P2(3,:)];
e2=inv(J2'*J2)*J2'*eigvec(3:4,2);
l2=P1*e2;
z2=T1*e2;
Q3=[-6*eye(4,4)-A' C'];
[S U V]=svd(Q3);
L3=V(:,5:8);
P3=L3(1:4,:);
T3=L3(5:8,:);
J3=[P3(1,:)+P3(4,:);P3(2,:)+P3(3,:)];
e3=inv(J3'*J3)*J3'*eigvec(1:2,3);
l3=P3*e3;
z3=T3*e3;
Q4=[-9*eye(4,4)-A' C'];
[S U V]=svd(Q4);
L4=V(:,5:8);
P4=L4(1:4,:);
T4=L4(5:8,:);
J4=[P4(1,:)+P4(4,:);P4(2,:)+P4(3,:)];
e4=[1;1;-inv(J4(:,[3,4]))*(J4(:,1)+J4(:,2)+J4(:,3))];
l4=P4*e4;
z4=T4*e4;
Z=[z1 z2 z3 z4];
l=[l1 l2 l3 l4];
K=(Z*inv(l))';
W=l1';

Contact us at files@mathworks.com