https://github.com/gramian/emgr
Raw File
Tip revision: cbcc2289c1b71e5ee8ec8a89aa016c35a1a1b889 authored by Christian Himpe on 05 May 2015, 13:06:33 UTC
release 3.1
Tip revision: cbcc228
balance_co.m
function [X Y Z] = balance_co(WC,WO)
% balance_co (balance controllability and observability gramians)
% by Christian Himpe, 2014-2015 ( http://gramian.de )
% released under BSD 2-Clause License ( opensource.org/licenses/BSD-2-Clause )
%*

[L,D,l] = svd(WC);
LC = L*diag(sqrt(diag(D)));

[L,D,l] = svd(WO);
LO = L*diag(sqrt(diag(D)));

[U,Y,V] = svd(LO'*LC);

% Y : Hankel Singular Values
X = ( LO*U*diag(1.0./sqrt(diag(Y))) )'; % Left Projection
Z =   LC*V*diag(1.0./sqrt(diag(Y))); % Right Projection

end
back to top