%
%   This script examplifies Exercise 2.7c in Matsys Gk
%

%   Given system
A = [ 2 4 3; 4 2 3; 4 4 4];
B = [1 -1 0; 1 1 -2]';
C = [2 2 -3];

%   Observability
omega = obsv(A,C)

%   Basis for Ker(omega) = S
a1 = [ 1 -1 0]';
a2 = [0 3 2]';

%   Basis for S complement
a3 = cross(a1,a2)

%   Change of variables
T = [ a3 a1 a2 ];

%   Transformed system
Atilde = inv(T)*A*T
Btilde = inv(T)*B;
Ctilde = C*T

% >> ex2_7
% 
% omega =
% 
%      2     2    -3
%      0     0     0
%      0     0     0
% 
% 
% a3 =
% 
%     -2
%     -2
%      3
% 
% 
% Atilde =
% 
%     0.0000         0   -0.0000
%    -3.0000   -2.0000   18.0000
%    -2.0000         0   10.0000
% 
% 
% Ctilde =
% 
%    -17     0     0
