You are on page 1of 20

Table of Contents

Discreption: ............................................................................................................... 1
Specification of Number of Boundary, force & measurement nodes ...................................... 1
Elimination of fixed points ............................................................................................ 2
Guyan Reduction of the massless rotational DOFs ............................................................. 2
Generating (A,B,C,D)of the Full Sys. .............................................................................. 2
Butterworth Filter Design ............................................................................................. 3
Response of Orginal .................................................................................................... 4
Balanced Truncation .................................................................................................... 6
Frequency Weighted Truncation .................................................................................... 8
Further Reduction Based on Akaike-like Criterion ........................................................... 11
Speedy Model Reduction ............................................................................................ 13
Bal. Trunc. For Distributed Load .................................................................................. 15
Appendix- subfunctions .............................................................................................. 19

Discreption:
This function is Written By Majid Khorsand Vakilzadeh
function Main
clc
clear
load Aluminum_Plate.mat
NDOFN = 6;
Ts = 1e-4;
Tf = (size(u0,2)-1)*1e-4;

% Number DOFs per node


% Sampeling Time

%--------------------------------------------------------------------------

Specification of Number of Boundary, force &


measurement nodes
-------------------------------------------------------------NdF(1) = cor2node([0,0,0],XYZ);
% Node# of 1st
NdF(2) = cor2node([0,0.5,0],XYZ);
% Node# of 2nd
NdF(3) = cor2node([.5,0.5,0],XYZ);
% Node# of 3rd
NdF(4) = cor2node([.5,0,0],XYZ);
% Node# of 4th
Fi_DOF =[];
for i = 1:4
Fi_DOF = [Fi_DOF (NdF(i)-1)*NDOFN+1:NdF(i)*NDOFN-3];
end
NdA(1) = cor2node([.125,.25,0],XYZ)-4;
NdA(2) = cor2node([.25,.25,0],XYZ)-4;
NdA(3) = cor2node([.125,.125,0],XYZ)-4;

boundary
boundary
boundary
boundary

condition
condition
condition
condition

%Should be Verified

% Node# of 1st accelerometer


% Node# of 2nd accelerometer
% Node# of 3rd accelerometer

NdForce = cor2node([.125,.25,0],XYZ)-4;
% Node# of force
% ------------------------------------------------------------------------1

Elimination of fixed points


--------------------------KX(Fi_DOF,:)=[];KX(:,Fi_DOF)=[];
MX(Fi_DOF,:)=[];MX(:,Fi_DOF)=[];
VX = 1e-3 * MX + 1e-6 * KX;

% Elimination of fixed points


% Elimination of fixed points
% Rayleigh Viscous Damping

% -------------------------------------------------------------------------

Guyan Reduction of the massless rotational


DOFs
----------------------------------------------ind=[];
% Indices of DOFs which should be kept in Guyan reduction
for i=2:16
ind = [ind 6*(i-2)+4:6*(i-2)+6];
end
for i=18:32
ind = [ind 6*(i-3)+7:6*(i-3)+9];
end
for i=34:48
ind = [ind 6*(i-4)+10:6*(i-4)+12];
end
for i=50:289
ind = [ind 6*(i-5)+13:6*(i-5)+15];
end
[Kgr,Vgr,Mgr] = guyan(KX,VX,MX,ind);

% Guyan Reduction of the DOFs

% -------------------------------------------------------------------------

Generating (A,B,C,D)of the Full Sys.


-------------------------------------

NuDOF = size(Kgr,1);
% Number of Degrees of freedom
[A,B1,Z]=kcm2ab(Kgr,Vgr,Mgr,NuDOF);
Tu = zeros(size(B1,2),1);Tu(NdForce*3,1) = 1; B = B1*Tu; % Tu is a map between for
C1 = zeros(3,size(B,1)); C1(1,NuDOF+NdA(1)*3)=1;
C1(2,NuDOF+NdA(2)*3)=1; C1(3,NuDOF+NdA(3)*3)=1;
C = C1 * A;
D = C1 * B;
EigA = sort(eig(full(A)));
disp(['The first five eigenvalues of the Full system is: '...
,num2str(EigA(1)),' ',num2str(EigA(2)),' ',num2str(EigA(3))...
,' ',num2str(EigA(4)),' ',num2str(EigA(5)),'.'])
disp(' ')
2

% -------------------------------------------------------------------------

The first five eigenvalues of the Full system is: -0.00148178-44.3121i -0.00148178+

Butterworth Filter Design


------------------------BF_Or = 16;
% Order of Butterworth Filter
W_Cut = 500;
% Cut off frequency in Hz
Nyq_Fr = 1/(2*Ts);
% Nyquist Frequency
Wn = W_Cut/Nyq_Fr;
[Ab,Bb,Cb,Db] = butter(BF_Or,Wn);
% Producing A, B, C, D of
BuSys = ss(Ab,Bb,Cb,Db,Ts);
[u1] = RespDisSys(Ab,Bb,Cb,Db,u0,Ts);
% The output of Filter
Nu1 = norm(u1,'fro');
% The Frobenius norm of filter output
disp(['The Frobenius norm of the stimulus is: ', num2str(Nu1)]);
disp(' ')
figure
T = 0 :1e-4:(size(u0,2)-1)*1e-4;
subplot(2,1,1);plot(T,u0);ylabel('raw load data (u0)');
title('Performance of Butterworth of Order 16');
subplot(2,1,2);plot(T,u1,'r -');ylabel('stimulus (u1)');xlabel('time (sec)');
% ------------------------------------------------------------------------The Frobenius norm of the stimulus is: 31.8788

Response of Orginal
-------------------

Osys = ss(A,B,C,D);
tic
Osysd = c2d(Osys,Ts);
% Discretization of the Full system
td = toc;
disp(['The simulation time for discretization of Full system is: ',num2str(td),' Se
tic
Y_Or = RespDisSys(Osysd.a,Osysd.b,Osysd.c,Osysd.d,u1,Ts);
t_or = toc;
disp(['The simulation time to obtain Y (response of full Sys.): ',num2str(t_or),' S
for i=1:3
% Computation of
FNY_Or(i) = norm(Y_Or(i,:),'fro');
end
disp(['The Frobenius norm of y1 (Full Sys.) is:
disp(['The Frobenius norm of y2 (Full Sys.) is:
disp(['The Frobenius norm of y3 (Full Sys.) is:
TotFNY_Or = norm(Y_Or,'fro');

Frobenius norm of full Sys.


',num2str(FNY_Or(1)),'.'])
',num2str(FNY_Or(2)),'.'])
',num2str(FNY_Or(3)),'.'])

figure
subplot(3,1,1);plot(T,Y_Or(1,:));ylabel('y1');
title('The response of the full system of order 1710')
subplot(3,1,2);plot(T,Y_Or(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_Or(3,:));ylabel('y3');xlabel('time(sec)')
figure
4

bode(Osysd)
title('The Bode plot of the discretized Full System')
% ------------------------------------------------------------------------Warning: The "a" matrix was converted from sparse to full.
The simulation time for discretization of Full system is: 3.5593 Sec
The simulation time to obtain Y (response of full Sys.): 16.3461 Sec
The Frobenius norm of y1 (Full Sys.) is: 8058.0612.
The Frobenius norm of y2 (Full Sys.) is: 6704.0235.
The Frobenius norm of y3 (Full Sys.) is: 4133.3353.

Balanced Truncation
------------------Coef = 1e-4;
% The ratio of the cutting gramian and the biggest gramian
tic
[Tsys, tre] = BalTrunc(Osysd,Coef,Ts);
t_b = toc;
fprintf('The number of retained states is: %4.1f ',size(Tsys.a,1))

tic
[Y_BTr] = RespDisSys(Tsys.a,Tsys.b,Tsys.c,Tsys.d,u1,Ts);
t_BTTr = toc;
disp(['The simulation time to obtain Y (response of Bal. Trunc. Sys.): ',num2str(t_
for i=1:3
% Computation
FNY_BTr(i) = norm(Y_BTr(i,:),'fro');
end
disp(['The Frobenius norm of y1 (Bal. Trunc.
disp(['The Frobenius norm of y2 (Bal. Trunc.
disp(['The Frobenius norm of y3 (Bal. Trunc.

of Frobenius norm of full Sys.


Sys.) is: ',num2str(FNY_BTr(1)),'.'])
Sys.) is: ',num2str(FNY_BTr(2)),'.'])
Sys.) is: ',num2str(FNY_BTr(3)),'.'])

TotFNY_BTr = norm(Y_BTr,'fro');
BTerr = Y_Or - Y_BTr;
% Computation of Error
for i=1:3
% Computation of Frobenius norm of full Sys.
FN_BTerr(i) = norm(BTerr(i,:),'fro');
end
disp(['The Frobenius norm of error1 is: ',num2str(FNY_BTr(1)),'.'])
6

disp(['The Frobenius norm of error2 is: ',num2str(FNY_BTr(2)),'.'])


disp(['The Frobenius norm of error3 is: ',num2str(FNY_BTr(3)),'.'])
FNBTerr = norm(BTerr,'fro');

% Computation of norm of error

% --- Plot of response of Full Sys.,Trun. Sys. --T = 0:1e-4:Tf;


figure
subplot(3,1,1);plot(T,Y_BTr(1,:));ylabel('y1');
title('The response of the Bal. Trunc. system of order 232')
subplot(3,1,2);plot(T,Y_BTr(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_BTr(3,:));ylabel('y3');xlabel('Time(sec)')
figure
subplot(3,1,1);plot(T,BTerr(1,:));ylabel('e1');
title('The Error between Full Sys. & Bal. Trunc. Sys.')
subplot(3,1,2);plot(T,BTerr(2,:));ylabel('e2');
subplot(3,1,3);plot(T,BTerr(3,:));ylabel('e3');xlabel('Time(sec)')
% ------------------------------------------------------------------------The
The
The
The
The
The
The
The

simulation time to balance the full system: 66.0299 Sec


number of retained states is: 232.0 The simulation time to obtain Y (response o
Frobenius norm of y1 (Bal. Trunc. Sys.) is: 8058.0411.
Frobenius norm of y2 (Bal. Trunc. Sys.) is: 6704.0194.
Frobenius norm of y3 (Bal. Trunc. Sys.) is: 4133.3276.
Frobenius norm of error1 is: 8058.0411.
Frobenius norm of error2 is: 6704.0194.
Frobenius norm of error3 is: 4133.3276.

Frequency Weighted Truncation


-----------------------------

tic
OutSysW = ss(-.8*eye(16),zeros(16,3),zeros(3,16),eye(3),1e-4);
FWBSys = Dis_FWBalancing(Tsys,BuSys,OutSysW,Ts);
% Frequency Weighted Balance
TFWBSys = FWBSys;

FNFWerr = 0;
while FNFWerr < .02 * TotFNY_Or
ind1 = [size(TFWBSys.a,2)-1,size(TFWBSys.a,2)];
% Indices for model reductio
TFWBSys = modred(TFWBSys,ind1,'MatchDC');
% Model order reduction using t
[Y_FWred] = RespDisSys(TFWBSys.a,TFWBSys.b,TFWBSys.c,TFWBSys.d,u1,Ts); %Resp o
FWerr = Y_Or - Y_FWred;
% Computation of Error
FNFWerr = norm(FWerr,'fro'); % Frobenius Norm of Balanced Truncated Sys.
end
t_FWBT = toc;
disp(['The simulation time for Further reduction with FWB method & to obtain its Y
figure
bode(TFWBSys)
title('The Bode plot of the FWBSystem')
% --- Plot of response of Full Sys.,Trun. Sys. --T = 0:1e-4:Tf;
figure
subplot(3,1,1);plot(T,Y_FWred(1,:));ylabel('y1');
title('The response of the Fre. Wieghted Bal. Trunc. system of order 182')
8

subplot(3,1,2);plot(T,Y_FWred(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_FWred(3,:));ylabel('y3');xlabel('Time(sec)')
figure
subplot(3,1,1);plot(T,FWerr(1,:));ylabel('e1');
title('The Error between Full Sys. & Fre. Weighted Bal. Trunc. Sys.')
subplot(3,1,2);plot(T,FWerr(2,:));ylabel('e2');
subplot(3,1,3);plot(T,FWerr(3,:));ylabel('e3');xlabel('Time(sec)')
% ------------------------------------------------------------------------%
Analyzing the performance of FWBT Sys.
%
---------------------------------------

G1 = [size(TFWBSys.a,2)+1:size(Tsys.a,1)];
FurTofBSys = modred(Tsys,G1,'MatchDC');
TFWBSys_Cont = d2c(TFWBSys);
FurTofBSys_Cont = d2c(FurTofBSys);
Tsys_Cont = d2c(Tsys);
Eval_1 = sort(imag(eig(FurTofBSys_Cont.a)))./2./pi;G_1 = find(Eval_1>500);
Eval_2 = sort(imag(eig(TFWBSys_Cont.a)))./2./pi;G_2 = find(Eval_2>500);
Eval_3 = sort(imag(eig(Tsys_Cont)))./2./pi;G_3 = find(Eval_3>500);
figure
stem(Eval_3(length(Eval_3)/2+1:end),1.1*ones(length(Eval_3(length(Eval_3)/2+1:end))
stem(Eval_1(length(Eval_1)/2+1:end),1*ones(length(Eval_1(length(Eval_1)/2+1:end))),
stem(Eval_2(length(Eval_2)/2+1:end),.9*ones(length(Eval_2(length(Eval_2)/2+1:end)))
title(['# of eigs above 500Hz: ', 'black-Full Sys.: ',num2str(length(G_3)),'green,B
% -------------------------------------------------------------------------

The simulation time for Further reduction with FWB method & to obtain its Y is: 4.1

10

Further Reduction Based on Akaike-like Criterion


-----------------------------------------------tic
W_n = FNFWerr/(size(TFWBSys.a,1))^2;
W_y = 1;
TFWBSys_A = TFWBSys;

Akaike_Cost =[];
i = 0;
for j = length(TFWBSys.a(:,1)):-2:4
i = i+1;
ind2 = [size(TFWBSys_A.a,2)-1,size(TFWBSys_A.a,2)];
TFWBSys_A = modred(TFWBSys_A,ind2,'MatchDC');
% Model order reduction usi
[Y_FWredA] = RespDisSys(TFWBSys_A.a,TFWBSys_A.b,TFWBSys_A.c,TFWBSys_A.d,u1,Ts);
FWerrA = Y_Or - Y_FWredA;
FNFWerrA(i) = norm(FWerrA,'fro'); % Frobenius Norm of Balanced Truncated Sys.
Akaike_Cost(i) = W_y*FNFWerrA(i) + W_n*size(TFWBSys_A.a,1)^2; % Akaike like cr
end
t_FWA = toc;
disp(['The simulation time for computation of the series of akaike-like criterion i
ir = length(TFWBSys.a(:,1)):-2:4;
figure
plot(ir,Akaike_Cost(:),'r *')
xlabel('State Number');ylabel('Value of Akaike-like criterion')
11

Min_A = min(Akaike_Cost);
Min_ind = find(Akaike_Cost==Min_A);
L_order = ir(Min_ind);
disp(['Order of system with min Akaike-like criterion: ', num2str(L_order)]);
ind2 = [L_order+1:size(TFWBSys.a,2)];
TFWBSys_A = modred(TFWBSys,ind2,'MatchDC');% Model order red. using MatchDC
[Y_FWredA]= RespDisSys(TFWBSys_A.a,TFWBSys_A.b,TFWBSys_A.c,TFWBSys_A.d,u1,Ts);
figure
subplot(3,1,1);plot(T,Y_FWredA(1,:));ylabel('y1');
title('The response of truncated Sys. With min Akaike-like criterion')
subplot(3,1,2);plot(T,Y_FWredA(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_FWredA(3,:));ylabel('y3');xlabel('Time(sec)')
% -------------------------------------------------------------------------

The simulation time for computation of the series of akaike-like criterion is: 3.68
Order of system with min Akaike-like criterion: 142

12

Speedy Model Reduction


----------------------

tic
[Evec,Eval] = eigs(Kgr,Mgr,200,'SM');
% 200 lowest frequency eigenmodes
t_Eig = toc;
disp(['The simulation time to solve eigenvalue problem is: ',num2str(t_Eig),' s.'])

Tnew = [Evec zeros(size(Evec));zeros(size(Evec)) Evec];% Similarity Trans.


A_Last = pinv(Tnew)*Osys.a*Tnew;
% Trans. State Matrix
B_Last = pinv(Tnew)*Osys.b;
% Trans. State Matrix
C_Last = Osys.c*Tnew;
% Trans. State Matrix
D_Last = Osys.d;
% Trans. State Matrix
Sys_Last = ss(A_Last,B_Last,C_Last,D_Last);
% Const of Sys.
Sys_Lastd = c2d(Sys_Last,Ts);
% Discr. of Sys.
tic
[BSys_Last,tres_last] = BalTrunc(Sys_Lastd,Coef,Ts);% Bal. Trun. of NewSys.
t_BEig = toc;
disp(['Time for balancing&truncation of the modally reduced system is: ',num2str(t
[Y_S] = RespDisSys(BSys_Last.a,BSys_Last.b,BSys_Last.c,BSys_Last.d,u1,Ts);
figure
bode(BSys_Last);
title('Bode plot of speedy truncated system')
T = 0:1e-4:Tf;
figure
13

subplot(3,1,1);plot(T,Y_S(1,:));ylabel('y1');
title('The response of Bal. Trunc. Sys. of the modally reduced system & the order i
subplot(3,1,2);plot(T,Y_S(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y_S(3,:));ylabel('y3');xlabel('Time(sec)')
% ------------------------------------------------------------------------The simulation time to solve eigenvalue problem is: 0.66206 s.
The simulation time to balance the full system: 1.2775 Sec
Time for balancing&truncation of the modally reduced system is: 1.2993 Sec
Warning: Imaginary parts of complex X and/or Y arguments ignored
Warning: Imaginary parts of complex X and/or Y arguments ignored
Warning: Imaginary parts of complex X and/or Y arguments ignored

14

Bal. Trunc. For Distributed Load


-------------------------------Tu1 = eye(size(B1,2),size(B1,2)); % Tu1 is a map between force & states
Bnew = B1*Tu1;
Dnew = C1 * Bnew;
Osys2 = ss(A,Bnew,C,Dnew);
Osys2d = c2d(Osys2,Ts);
tic
[Rsys2, Grm2] = balreal(Osys2d);
tt=toc;
disp(['Time for balancing of the original system is: ',num2str(tt),' Sec.'])
treshold2 = Coef*Grm2(1);
G2 = find(Grm2<(Coef*Grm2(1)));
if mod(G2(1),2) == 0
G2(1) = [];
end
Tsys2 = modred(Rsys2,G2,'MatchDC');
fprintf('The number of retained states for distributed load is %4.1f',G2(1)-1)
[TBY2] = RespDisSys(Tsys2.a,Tsys2.b,Tsys2.c,Tsys2.d,Ul,Ts);
[Y2] = RespDisSys(Osys2d.a,Osys2d.b,Osys2d.c,Osys2d.d,Ul,Ts);
TSOrd = num2str(size(Tsys2.a,1));
T = 0:1e-4:Tf;
figure
subplot(3,1,1);plot(T,Y2(1,:)); ylabel('y1');
title('Response of original system (Distributed Load)')
subplot(3,1,2);plot(T,Y2(2,:)); ylabel('y2');
15

subplot(3,1,3);plot(T,Y2(3,:)); ylabel('y3');
xlabel('time(sec)')
figure
subplot(3,1,1);plot(T,TBY2(1,:));ylabel('y1');
title(['Response of truncated system of order: ',TSOrd,'(Distributed Load'])
subplot(3,1,2);plot(T,TBY2(2,:));ylabel('y2');
subplot(3,1,3);plot(T,TBY2(3,:));ylabel('y3');
xlabel('time(sec)')

% -------------------------------- SVD based bal. Trun. of Distributed Load


[U,S,V] = svd(Ul);
B1new = Bnew*U;
D1new = Dnew*U;
unew = S(:,1:size(S,1))*V(:,1:size(S,1))';
Osys21 = ss(A,B1new,C,D1new);
Osys21d = c2d(Osys21,Ts);
tic
[Rsys21, Grm21] = balreal(Osys21d);
ttt=toc;
disp(['Time for balancing of the original system for SVD based distributed load is:
treshold21 = Coef*Grm21(1);
G21 = find(Grm21<(Coef*Grm21(1)));
if mod(G21(1),2) == 0
G21(1) = [];
end
Tsys21 = modred(Rsys21,G21,'MatchDC');
fprintf('The number of retained states of SVD based distributed load is %4.1f',G21(
[TBY21] = RespDisSys(Tsys21.a,Tsys21.b,Tsys21.c,Tsys21.d,unew,Ts);
[Y21] = RespDisSys(Osys21d.a,Osys21d.b,Osys21d.c,Osys21d.d,unew,Ts);
SysOrd = num2str(size(Osys21d.a,1));
T = 0:1e-4:Tf;
figure
subplot(3,1,1);plot(T,Y21(1,:));ylabel('y1');
title('Response of original system of SVD based distributed load')
subplot(3,1,2);plot(T,Y21(2,:));ylabel('y2');
subplot(3,1,3);plot(T,Y21(3,:));ylabel('y3');
xlabel('time (sec)')
figure
subplot(3,1,1); plot(T,TBY21(1,:));ylabel('y1');
title(['Response of truncated system of order is: ',SysOrd,'(SVD Based Distributed
subplot(3,1,2); plot(T,TBY21(2,:));ylabel('y2');
subplot(3,1,3); plot(T,TBY21(3,:));ylabel('y3');
xlabel('time (sec)')

Warning: The "a" matrix was converted from sparse to full.


Time for balancing of the original system is: 67.7571 Sec.
The number of retained states for distributed load is 462.0Warning: The "a" matrix
Time for balancing of the original system for SVD based distributed load is: 75.097
The number of retained states of SVD based distributed load is 462.0

16

17

18

end
% -------------------------------------------------------------------------

Appendix- subfunctions
---------------------function NdI = cor2node(NdC,XYZ)
NdI = 0;
for i = 1:size(XYZ,1)
NdN = find(NdC==XYZ(i,:));
if size(NdN,2) == 3
NdI = i;
end
end
if NdI == 0
fprintf('The Coordination matrix does not contain this node')
end
end
function [Y1] = RespDisSys(A,B,C,D,u,Ts)
X = ltitr(A,B,u'); % Response of Original
Y1 = C*X'+D*u;
end

system to u0

function [Tsys, treshhold] = BalTrunc(sys,Coef,Ts)


tic
[Rsys, Grm] = balreal(sys);
t_b=toc;
disp(['The simulation time to balance the full system: '...
,num2str(t_b),' Sec'])
treshhold = Coef*Grm(1);
G = find(Grm<(Coef*Grm(1)));
if mod(G(1),2) == 0
G(1) = [];
end
Tsys = modred(Rsys,G,'MatchDC');
end
function FWBSys = Dis_FWBalancing(SYS,InW,OutW,Ts)
%
%
%
%
%
%
%
%
%

Target: To transform a system to balanced form based on the input&output


frequency Weights
SYS: The original system
InW: Input Frequency Weight system
OutW: Output Frequency Weight system
FWBSys: Frequency Weighted Balanced Sys.
Reference: A frequency-weighted discrete system balanced truncation
method and an error bound

%--------------- Realization of the Input System & Output system


A_I = [SYS.a,SYS.b*InW.c;zeros(size(InW.a,1),size(SYS.a,2)),InW.a];
B_I = [SYS.b*InW.d; InW.b];
A_O = [SYS.a
OutW.b*SYS.c
C_O = [OutW.d*SYS.c

zeros(size(SYS.a,1),size(OutW.a,2))
OutW.a
];
OutW.c];

% -------- Input Controllability Gramian & Output Observability Gramian


19

P_hat_i = dlyap(A_I,B_I*B_I');P_I = P_hat_i;


Q_hat_o = dlyap(A_O',C_O'*C_O);Q_O = Q_hat_o;
P_I(:,size(SYS.a,1)+1:end)=[];P_I(size(SYS.a,1)+1:end,:)=[];
Q_O(:,size(SYS.a,1)+1:end)=[];Q_O(size(SYS.a,1)+1:end,:)=[];
% -------- Computation algorithm to obtain new positive definite gramians
X_P_I = -(SYS.a*P_I*SYS.a'-P_I);
[Vec_X,Val_X] = eig(X_P_I);
B_hat = Vec_X * sqrt(abs(Val_X));
P_new = dlyap(SYS.a,B_hat*B_hat');
Y_P_I = -(SYS.a'*Q_O*SYS.a-Q_O);
[Vec_Y,Val_Y] = eig(Y_P_I);
C_hat = sqrt(abs(Val_Y)) * Vec_Y';
Q_new = dlyap(SYS.a',C_hat'*C_hat);
% -------- Computation of balancing similarity matrix
UU = chol(P_new);
[K,Sigma] = eig(UU'*Q_new*UU);
T = sqrt(sqrt(Sigma))*K'*UU^-1;
Tinv = UU*K*sqrt(sqrt(Sigma))^-1;
Pbal = T*P_new*T';
Qbal = Tinv'*Q_new*Tinv;
% -------- Transformation of the system to balanced form
A_FWba = T*SYS.a*Tinv;
B_FWba = T*SYS.b;
C_FWba = SYS.c *Tinv;
D_FWba = SYS.d;
FWBSys = ss(A_FWba,B_FWba,C_FWba,D_FWba,Ts); % Fre. Weighted Bal. Sys.
end

Published with MATLAB 7.11

20

You might also like