clear
clc

Lf = .3;
Cf = 1;

A = [0 -1/Lf;
     1/Cf 0];
B = [1/Lf; 0];
C = [1,0; 0, 1];
 
%task 1: Luenberger observer
L = place(A,C',[-1,-1]);
x0_luen = [0;5];

%task 2: add noise
%measurement noise
rv1 = 1;
rv2 = 1;
%process noise
rw1 = 1e-3;
rw2 = 1e-3;

%task 3: recursive Kalman
x0_kalman = [0;5];
P0 = ones(2,2);

%task 4: error covariance and riccati
% 0 = A*P + P*A' - P*C'*inv(Rw)*C*P' + Rv;

%task 5: LQR
Q = [.1,0;
     0 1];
R = .01;
K = lqr(A,B,Q,R,0);

%task 6: partial measurement
C2 = [1,0];

%task 7
%x0_kalman = [0;5];