t = [ 0 : 0.02 : 4]';
 u = 0 .* t ;	% ZIR, OR
% u = cos(t);	% Enter desired input here
n = length(t);

% System

A  = [ 0 1 0; 0 0 1; -6 -11 -6 ];
B  = [ 0 ; 0 ; 1 ];
C  = [ 1 0 0 ];
D  = 0;
x0 = [ -1 ; 1 ; 1]

[y,     x]     = lsim(A,B,C,D,u,t,x0);

% Observer

H = [ 3 ; 7; -1 ];
F = A - H * C;
Co= [ 1 0 0 ];
Bo= [B, H];
Uo= [u, y];
Do= [0 0];

% simulation

[y_hat, x_hat] = lsim(F,Bo,Co,Do,Uo,t);
plot(t,     x(:,1),'r-',t,       x(:,2),'g-',t,      x(:,3),'b-', ...
     t, x_hat(:,1),'r--' ,t, x_hat(:,2),'g--' ,t,x_hat(:,3),'b--' )
xlabel('Time in seconds')
TITLE('Full Order Observer and System response: ZIR')
legend('x_1','x_2','x_3');
