function p16_tst
% May16, JG

% system G(s)=1/s^2:

A= [0 1; 0 0];
B= [0 1]';
C= [1 0];
D= 0;

% method 1: pole placement as suggested by Chang-Letov's theorem

sp= 2*exp(j*pi*5/4); % pole value computed in the class
K= acker( A, B, [sp conj(sp)])

% method 1b: pole placement as suggested by Chang-Letov's theorem

sp= roots([1 0 0 0 16]); sp= sp( real(sp)<0 );
K= acker(A, B, sp )

% method 2: formulation as a Linear Quadratic Regulator (LQR):

Q= C'*C;
R= 1/16;
K= lqr( A, B, Q, R)

% LQR implies closed loop stability. See it in the poles:

eig(A - B*K)
