% Define continuous-time process
A = [0 1; 0 0];
B = [0; 1];
C = [1 0];

% Sample the process using ZOH
h = 0.44;
[Phi,Gamma] = c2d(A,B,h)
Hp = ss(Phi,Gamma,C,0,h)

% Specify desired poles in continuous time
omega = 1; zeta = 0.7;  
pc = roots([1 2*zeta*omega omega^2])
% Calculate corresponding desired discrete-time poles
pd = exp(pc*h)

% Design state feedback
L = place(Phi,Gamma,pd)

% Define augmented system and design observer
Gammae = [Gamma; 0]
Phie = [Phi Gamma; zeros(1,2) 1];
Ce = [C 0];
Ke = acker(Phie',Ce',[0.75 0.75 0.75])'
Le = [L 1]

% Form complete controller
Hc = ss(Phie-Gammae*Le-Ke*Ce,Ke,Le,0,h)
bode(Hc)         % draw controller Bode plot
margin(Hp*Hc)    % check stability margins
