t = [ 0 : 0.1 : 4]';
u = 0 .* t;

% System

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

% Observer

H = [ 3 ; 4 ]
F = A - H * C

% simulation

[y,     x]     = lsim(A,B,C,D,u,t,x0);
[y_hat, x_hat] = lsim(F,H,C,D,y,t);
plot(t,     x(:,1),'r-',t,       x(:,2),'g-', t, x_hat(:,1),'r--' ,t, x_hat(:,2),'g--'  )
xlabel('Time in seconds')
TITLE('Simple Example of a Second Order Syatem: ZIR')
legend('x_1','x_2');
