Contoh skrip simulasi H2 dan Hinf

Berikut skrip simulasi H2 dan Hinf

%H2 regular state feedback case

s = tf(‘s’); %

A = [5 2;3 4]; % matriks A
B = [0;1];% matriks B
E = [1;2]; % matriks E
C1 = 1; % matriks C1
C2 = [1 1]; % matriks C2
D2 = 1; % matriks D2

%sesuaikan dg toolbox are–>help ARE
Ab = A-Binv(D2′D2)D2′C2; % matriks A augmented
Bb = Binv(D2′D2)B’; % matriks B augmented
Cb = C2′
C2-C2′D2inv(D2′D2)D2′C2; % matriks C augmented
P = are(Ab,Bb,Cb) %
F = -inv(D2′
D2)(D2′C2+B’*P)

gamma2star = sqrt(trace(E’PE)) %menghitung infinum H2
Tzw = (C2+D2F)inv(seye(size(A))-A-BF)*E; %membentuk fungsi alih respon output terkendali z terhadap gangguan w

x = logspace(-2,4);
semilogx(x,sigma(Tzw,x))

 

%Hinf state feedback

clc;close all
%[P,L,G]=care(A,B,Q,R)
%A’P+PA+1/gamma^2 PEE’P-(PB+C2’D2)(D2’D2)^(-1)(PB+C2’D2)’
A=[5 2;3 4];B=[0;1];E=[1;2];C2=[1 1];D2=1;
Q=C2′C2;
R=D2′
D2;
S=C2′D2;
%nilai terbaik dari gamma–> cost function
gama=5.0001
A1=A-B
inv(R)S’;
B1=[B E];
R1inv=[inv(R) 0;0 -1/gama^2];R1=inv(R1inv);
Q1=S
inv(R)S’-Q;
[P,L,L1]= care(A1,B1,Q1,R1)
F=-inv(R)
(B’*P+S’)

Ac=A+BF;
Cc=C2+D2
F;
Bc=E;
Dc=0;
[num,den]=ss2tf(Ac,Bc,Cc,Dc);
Tzw=tf(num,den);
%bode(sys)
x = logspace(-2,4);semilogx(x,sigma(Tzw,x)); % plot grafik
xlabel(‘Frekuensi (rad/s)’);ylabel(‘Magnitudo’);title(‘Tzw’)

%Hinf singular with small perturb epsi

clc;close all
%[P,L,G]=care(A,B,Q,R)
%A’P+PA+1/gamma^2 PEE’P-(PB+C2’D2)(D2’D2)^(-1)(PB+C2’D2)’
A=[5 2;3 4];B=[0;1];E=[1;2];
epsi=0.001;
%C2 = [1 1]; % matriks C2
C2=[1 1;epsi 0;0 epsi;0 0]
%D2 = 1; % matriks D2
D2=[0;0;0;epsi]

Q=C2’*C2;

R=D2′D2;
S=C2′
D2;
gama=0.6;
A1=A-Binv(R)S’;
B1=[B E];
R1inv=[inv(R) 0;0 -1/gama^2];R1=inv(R1inv);
%Q1=Sinv(R)S’-Q;
Q1=[0 0;0 0];
P= care(A1,B1,Q1,R1)

F=-inv(R)(B’P+S’)

Ac=A+BF;
Cc=C2+D2
F;
Bc=E;
Dc=[0;0;0;0];
[num,den]=ss2tf(Ac,Bc,Cc,Dc);
Tzw=tf(num,den);
%bode(sys)
x = logspace(-2,4);semilogx(x,sigma(Tzw,x)); % plot grafik
xlabel(‘Frekuensi (rad/s)’);ylabel(‘Magnitudo’);title(‘Tzw’)

Leave a Reply