function [K,Ko,P]=lpe2(A,C,c)
% LPE2 Linear Polynomial observer and Estimator
% [K,Ko,P]=lpe2(A,C,c)
% On input
% A, C - model matrices
% c - (n+1) dimensional vector with the prescribed coefficients
%     of the observer pole polynomial.

[m,n]=size(C);

% Compute the polynomial evaluation, P(A)
P=polyvalm(c,A);
On=obsv(A,C);

% Observer gain in observer form model..
Ko=C*P*inv(On); 
Ko=rot90(Ko);   % Gain in observer form (not needed)
Oi=inv(On);
K=P*Oi(:,n );   % Estimator gain in original coordinate system.
% END LPE2