function [Ao,Bo,Co,T]=ss2ocf(A,B,C)
% ss2cof 
% [Ao,Bo,Co,T]=ss2ocf(A,B,C)
% Transform a state space model
% dot(x)=Ax + Bu, y=Cx
% with the transformation, x=T xo
% to observer canonical form
% dot(xo)=Ao xo + Bo u, y=Co xo
%
a=poly(A);
n=length(a);
On=obsv(A,C);
M=triu(toeplitz([1,a(2:n-1)]))
T=inv(M'*On);
Ao=inv(T)*A*T;
Bo=inv(T)*B;
Co=C*T;
% END SS2OCF