MATLAB |
%cSPIN_of_gs.m
%-----
clear all close all
J1=1; J2=1; J3=0.5;
OMnom=2*pi; OMmin=0*OMnom; OMmax=2*OMnom;
% sim("SPIN0")
A1=[0 (J2-J3)/J1;(J3-J1)/J2 0];
B=diag([1/J1 1/J2]); C=eye(2); D=zeros(2,2);
S0=[zeros(2,2) B;C D];
S1=zeros(4,4); S1(1:2,1:2)=A1;
% sim("SPIN")
%-----
J1=1; J2=1; J3=0.5;
OMnom=2*pi; OMmin=0*OMnom; OMmax=2*OMnom;
A1= OMmin*[0 (J2-J3)/J1;(J3-J1)/J2 0];
A2= OMmax*[0 (J2-J3)/J1;(J3-J1)/J2 0];
B=diag([1/J1 1/J2]);
B1=B; B2=B;
C1=[eye(2,2);zeros(2,2)];
D11=zeros(4,2);
D12=[zeros(2,2);eye(2,2)];
C2=eye(2,2);
D21=zeros(2,2);
D22=zeros(2,2);
%-----
alpha=1; r=3; th=pi/4;
LMIs=of_synlmi7(A1,A2,B1,B2,C1,C2,D11,D12,D21,D22,alpha,r,th);
cobj=zeros(1,decnbr(LMIs));
cobj(1)=1;
[cost,xopt]=mincx(LMIs,cobj);
gopt=dec2mat(LMIs,xopt,1)
R=dec2mat(LMIs,xopt,2);
S=dec2mat(LMIs,xopt,3);
%-----
ak1=dec2mat(LMIs,xopt,4);
bk1=dec2mat(LMIs,xopt,5);
ck1=dec2mat(LMIs,xopt,6);
dk1=dec2mat(LMIs,xopt,7);
[u,sd,v]=svd(eye(size(A1,1))-R*S);
sd=diag(sqrt(1./diag(sd)));
Ni=sd*v'; Mti=u*sd;
AK1=Ni*(ak1-S*(A1-B2*dk1*C2)*R-bk1*C2*R-S*B2*ck1)*Mti;
BK1=Ni*(bk1-S*B2*dk1);
CK1=(ck1-dk1*C2*R)*Mti;
DK1=dk1;
K1=[AK1 BK1;CK1 DK1];
ACL1=[A1+B2*DK1*C2 B2*CK1;
BK1*C2 AK1];
plCL1=eig(ACL1)
%-----
ak2=dec2mat(LMIs,xopt,8);
bk2=dec2mat(LMIs,xopt,9);
ck2=dec2mat(LMIs,xopt,10);
dk2=dec2mat(LMIs,xopt,11);
[u,sd,v]=svd(eye(size(A2,1))-R*S);
sd=diag(sqrt(1./diag(sd)));
Ni=sd*v'; Mti=u*sd;
AK2=Ni*(ak2-S*(A2-B2*dk2*C2)*R-bk2*C2*R-S*B2*ck2)*Mti;
BK2=Ni*(bk2-S*B2*dk2);
CK2=(ck2-dk2*C2*R)*Mti;
DK2=dk2;
K2=[AK2 BK2;CK2 DK2];
ACL2=[A2+B2*DK2*C2 B2*CK2;
BK2*C2 AK2];
plCL2=eig(ACL2)
%------
figure(1)
subplot(121),dregion(alpha,0,r,th,r*[-1,1,-1,1])
plot(real(plCL1),imag(plCL1),'*')
subplot(122), dregion(alpha,0,r,th,r*[-1,1,-1,1])
plot(real(plCL2),imag(plCL2),'*')
%-----
prange=OMmax-OMmin; pmax=OMmax; pmin=OMmin;
%sim("SPIN_of_gs")
sim("SPIN_of_gs_2015a")
%-----
function LMIs=of_synlmi7(A1,A2,B1,B2,C1,C2,D11,D12,D21,D22,alpha,r,th)
[n,m]=size(B2); [p,n]=size(C2);
setlmis([]);
gam=lmivar(1,[1 0]);
[R,xxx,Rdec]=lmivar(1,[n 1]);
[S,xxx,Sdec]=lmivar(1,[n 1]);
Ak1=lmivar(2,[n n]);
Bk1=lmivar(2,[n p]);
Ck1=lmivar(2,[m n]);
Dk1=lmivar(2,[m p]);
Ak2=lmivar(2,[n n]);
Bk2=lmivar(2,[n p]);
Ck2=lmivar(2,[m n]);
Dk2=lmivar(2,[m p]);
%=====
lmiRS1=newlmi;
lmiterm([lmiRS1 1 1 R],A1,1,'s'); %#1:R*A'+AR
lmiterm([lmiRS1 1 1 Ck1],B2,1,'s'); %#1:Ck'*B2'+B2*Ck
lmiterm([lmiRS1 2 1 0],A1'); %#1:A'
lmiterm([lmiRS1 2 1 Ak1],1,1); %#1:Ak
lmiterm([lmiRS1 2 1 -Dk1],C2',B2'); %#1:C2'*Dk'*B2'
lmiterm([lmiRS1 2 2 S],1,A1,'s'); %#1:A'*S+S*A
lmiterm([lmiRS1 2 2 Bk1],1,C2,'s'); %#1:C2'*Bk'+Bk*C2
lmiterm([lmiRS1 1 3 0],B1); %#1:B1
lmiterm([lmiRS1 1 3 Dk1],B2,D21); %#1:B2*Dk*D21
lmiterm([lmiRS1 2 3 S],1,B1); %#1:S*B1
lmiterm([lmiRS1 2 3 Bk1],1,D21); %#1:Bk*D21
lmiterm([lmiRS1 3 3 gam],-1,1); %#1:-gam
lmiterm([lmiRS1 4 1 R],C1,1); %#1:C1*R
lmiterm([lmiRS1 4 1 Ck1],D12,1); %#1:D12*Ck
lmiterm([lmiRS1 4 2 0],C1); %#1:C1
lmiterm([lmiRS1 4 2 Dk1],D12,C2); %#1:D12*Dk*C2
lmiterm([lmiRS1 4 3 0],D11); %#1:D11
lmiterm([lmiRS1 4 3 Dk1],D12,D21); %#1:D12*Dk*D21
lmiterm([lmiRS1 4 4 gam],-1,1); %#1:-gam
%-----
lmiPL11=newlmi;
lmiterm([lmiPL11 1 1 R],A1,1,'s'); %#2:R*A'+A*R
lmiterm([lmiPL11 1 1 Ck1],B2,1,'s'); %#2:Ck'*B2'+B2*Ck
lmiterm([lmiPL11 2 1 Ak1],1,1); %#2:Ak
lmiterm([lmiPL11 1 2 0],A1); %#2:A
lmiterm([lmiPL11 1 2 Dk1],B2,C2); %#2:B2*Dk*C2
lmiterm([lmiPL11 2 2 S],1,A1,'s'); %#2:A'*S+S*A
lmiterm([lmiPL11 2 2 Bk1],1,C2,'s'); %#2:C2'*Bk'+Bk*C2
%
lmiterm([lmiPL11 1 1 R],2*alpha,1); %#2:2*alpha*R
lmiterm([lmiPL11 2 1 0],2*alpha); %#2:2*alpha*I
lmiterm([lmiPL11 2 2 S],2*alpha,1); %#2:2*alpha*S
%-----
lmiPL21=newlmi;
lmiterm([lmiPL21 1 1 R],-r,1); %#3:-r*R
lmiterm([lmiPL21 2 1 0],-r); %#3:-r*I
lmiterm([lmiPL21 2 2 S],-r,1); %#3:-r*S
%
lmiterm([lmiPL21 1 3 R],A1,1); %#3:A*R
lmiterm([lmiPL21 1 3 Ck1],B2,1); %#3:B2*Ck
lmiterm([lmiPL21 2 3 Ak1],1,1); %#3:Ak
lmiterm([lmiPL21 1 4 0],A1); %#3:A
lmiterm([lmiPL21 1 4 Dk1],B2,C2); %#3:B2*Dk*C2
lmiterm([lmiPL21 2 4 S],1,A1); %#3:S*A
lmiterm([lmiPL21 2 4 Bk1],1,C2); %#3:Bk*C2
%
lmiterm([lmiPL21 3 3 R],-r,1); %#3:-r*R
lmiterm([lmiPL21 4 3 0],-r); %#3:-r*I
lmiterm([lmiPL21 4 4 S],-r,1); %#3:-r*S
%-----
sth=sin(th); cth=cos(th);
lmiPL31=newlmi;
lmiterm([lmiPL31 1 1 R],sth*A1,1,'s'); %#4:sth*(R*A'+A*R)
lmiterm([lmiPL31 1 1 Ck1],sth*B2,1,'s');%#4:sth*(Ck'*B2'+B2*Ck)
lmiterm([lmiPL31 2 1 Ak1],sth,1); %#4:sth*(Ak)
lmiterm([lmiPL31 1 2 0],sth*A1); %#4:sth*(A)
lmiterm([lmiPL31 1 2 Dk1],sth*B2,C2); %#4:sth*(B2*Dk*C2)
lmiterm([lmiPL31 2 2 S],1,sth*A1,'s'); %#4:sth*(A'*S+S*A)
lmiterm([lmiPL31 2 2 Bk1],1,sth*C2,'s');%#4:sth*(C2'*Bk'+Bk*C2)
%
lmiterm([lmiPL31 1 3 R],cth*A1,1); %#1:cth*(A*R)
lmiterm([lmiPL31 1 3 R],1,-cth*A1'); %#1:cth*(-R*A')
lmiterm([lmiPL31 1 3 Ck1],cth*B2,1); %#1:cth*(B*Ck)
lmiterm([lmiPL31 1 3 -Ck1],-cth*B2',1); %#1:cth*(-Ck'*B')
lmiterm([lmiPL31 2 3 Ak1],cth,1); %#4:cth*(Ak)
lmiterm([lmiPL31 1 4 -Ak1],-cth,1); %#4:cth*(-Ak')
lmiterm([lmiPL31 1 4 0],A1); %#4:cth*(A)
lmiterm([lmiPL31 2 3 0],-A1'); %#4:cth*(-A')
lmiterm([lmiPL31 1 4 Dk1],cth*B2,C2); %#4:cth*(B2*Dk*C2)
lmiterm([lmiPL31 2 3 -Dk1],-cth*C2',B2');%#4:cth*(-C2'*Dk'*B2')
lmiterm([lmiPL31 2 4 S],1,cth*A1); %#4:cth*(S*A)
lmiterm([lmiPL31 2 4 S],-cth*A1',1); %#4:cth*(-A'*S)
lmiterm([lmiPL31 2 4 Bk1],1,cth*C2); %#4:cth*(Bk*C2)
lmiterm([lmiPL31 2 4 -Bk1],-cth*C2',1); %#4:cth*(-C2'*Bk')
%
lmiterm([lmiPL31 3 3 R],sth*A1,1,'s'); %#4:sth*(R*A'+A*R)
lmiterm([lmiPL31 3 3 Ck1],sth*B2,1,'s');%#4:sth*(Ck'*B2'+B2*Ck)
lmiterm([lmiPL31 4 3 Ak1],sth,1); %#4:sth*(Ak)
lmiterm([lmiPL31 3 4 0],sth*A1); %#4:sth*(A)
lmiterm([lmiPL31 3 4 Dk1],sth*B2,C2); %#4:sth*(B2*Dk*C2)
lmiterm([lmiPL31 4 4 S],1,sth*A1,'s'); %#4:sth*(A'*S+S*A)
lmiterm([lmiPL31 4 4 Bk1],1,sth*C2,'s');%#4:sth*(C2'*Bk'+Bk*C2)
%=====
lmiRS2=newlmi;
lmiterm([lmiRS2 1 1 R],A2,1,'s'); %#1:R*A'+AR
lmiterm([lmiRS2 1 1 Ck2],B2,1,'s'); %#1:Ck'*B2'+B2*Ck
lmiterm([lmiRS2 2 1 0],A2'); %#1:A'
lmiterm([lmiRS2 2 1 Ak2],1,1); %#1:Ak
lmiterm([lmiRS2 2 1 -Dk2],C2',B2'); %#1:C2'*Dk'*B2'
lmiterm([lmiRS2 2 2 S],1,A2,'s'); %#1:A'*S+S*A
lmiterm([lmiRS2 2 2 Bk2],1,C2,'s'); %#1:C2'*Bk'+Bk*C2
lmiterm([lmiRS2 1 3 0],B1); %#1:B1
lmiterm([lmiRS2 1 3 Dk2],B2,D21); %#1:B2*Dk*D21
lmiterm([lmiRS2 2 3 S],1,B1); %#1:S*B1
lmiterm([lmiRS2 2 3 Bk2],1,D21); %#1:Bk*D21
lmiterm([lmiRS2 3 3 gam],-1,1); %#1:-gam
lmiterm([lmiRS2 4 1 R],C1,1); %#1:C1*R
lmiterm([lmiRS2 4 1 Ck2],D12,1); %#1:D12*Ck
lmiterm([lmiRS2 4 2 0],C1); %#1:C1
lmiterm([lmiRS2 4 2 Dk2],D12,C2); %#1:D12*Dk*C2
lmiterm([lmiRS2 4 3 0],D11); %#1:D11
lmiterm([lmiRS2 4 3 Dk2],D12,D21); %#1:D12*Dk*D21
lmiterm([lmiRS2 4 4 gam],-1,1); %#1:-gam
%-----
lmiPL12=newlmi;
lmiterm([lmiPL12 1 1 R],A2,1,'s'); %#2:R*A'+A*R
lmiterm([lmiPL12 1 1 Ck2],B2,1,'s'); %#2:Ck'*B2'+B2*Ck
lmiterm([lmiPL12 2 1 Ak2],1,1); %#2:Ak
lmiterm([lmiPL12 1 2 0],A2); %#2:A
lmiterm([lmiPL12 1 2 Dk2],B2,C2); %#2:B2*Dk*C2
lmiterm([lmiPL12 2 2 S],1,A2,'s'); %#2:A'*S+S*A
lmiterm([lmiPL12 2 2 Bk2],1,C2,'s'); %#2:C2'*Bk'+Bk*C2
%
lmiterm([lmiPL12 1 1 R],2*alpha,1); %#2:2*alpha*R
lmiterm([lmiPL12 2 1 0],2*alpha); %#2:2*alpha*I
lmiterm([lmiPL12 2 2 S],2*alpha,1); %#2:2*alpha*S
%-----
lmiPL22=newlmi;
lmiterm([lmiPL22 1 1 R],-r,1); %#3:-r*R
lmiterm([lmiPL22 2 1 0],-r); %#3:-r*I
lmiterm([lmiPL22 2 2 S],-r,1); %#3:-r*S
%
lmiterm([lmiPL22 1 3 R],A2,1); %#3:A*R
lmiterm([lmiPL22 1 3 Ck2],B2,1); %#3:B2*Ck
lmiterm([lmiPL22 2 3 Ak2],1,1); %#3:Ak
lmiterm([lmiPL22 1 4 0],A2); %#3:A
lmiterm([lmiPL22 1 4 Dk2],B2,C2); %#3:B2*Dk*C2
lmiterm([lmiPL22 2 4 S],1,A2); %#3:S*A
lmiterm([lmiPL22 2 4 Bk2],1,C2); %#3:Bk*C2
%
lmiterm([lmiPL22 3 3 R],-r,1); %#3:-r*R
lmiterm([lmiPL22 4 3 0],-r); %#3:-r*I
lmiterm([lmiPL22 4 4 S],-r,1); %#3:-r*S
%-----
sth=sin(th); cth=cos(th);
lmiPL32=newlmi;
lmiterm([lmiPL32 1 1 R],sth*A2,1,'s'); %#4:sth*(R*A'+A*R)
lmiterm([lmiPL32 1 1 Ck2],sth*B2,1,'s');%#4:sth*(Ck'*B2'+B2*Ck)
lmiterm([lmiPL32 2 1 Ak2],sth,1); %#4:sth*(Ak)
lmiterm([lmiPL32 1 2 0],sth*A2); %#4:sth*(A)
lmiterm([lmiPL32 1 2 Dk2],sth*B2,C2); %#4:sth*(B2*Dk*C2)
lmiterm([lmiPL32 2 2 S],1,sth*A2,'s'); %#4:sth*(A'*S+S*A)
lmiterm([lmiPL32 2 2 Bk2],1,sth*C2,'s');%#4:sth*(C2'*Bk'+Bk*C2)
%
lmiterm([lmiPL32 1 3 R],cth*A2,1); %#1:cth*(A*R)
lmiterm([lmiPL32 1 3 R],1,-cth*A2'); %#1:cth*(-R*A')
lmiterm([lmiPL32 1 3 Ck2],cth*B2,1); %#1:cth*(B*Ck)
lmiterm([lmiPL32 1 3 -Ck2],-cth*B2',1); %#1:cth*(-Ck'*B')
lmiterm([lmiPL32 2 3 Ak2],cth,1); %#4:cth*(Ak)
lmiterm([lmiPL32 1 4 -Ak2],-cth,1); %#4:cth*(-Ak')
lmiterm([lmiPL32 1 4 0],A2); %#4:cth*(A)
lmiterm([lmiPL32 2 3 0],-A2'); %#4:cth*(-A')
lmiterm([lmiPL32 1 4 Dk2],cth*B2,C2); %#4:cth*(B2*Dk*C2)
lmiterm([lmiPL32 2 3 -Dk2],-cth*C2',B2');%#4:cth*(-C2'*Dk'*B2')
lmiterm([lmiPL32 2 4 S],1,cth*A2); %#4:cth*(S*A)
lmiterm([lmiPL32 2 4 S],-cth*A2',1); %#4:cth*(-A'*S)
lmiterm([lmiPL32 2 4 Bk2],1,cth*C2); %#4:cth*(Bk*C2)
lmiterm([lmiPL32 2 4 -Bk2],-cth*C2',1); %#4:cth*(-C2'*Bk')
%
lmiterm([lmiPL32 3 3 R],sth*A2,1,'s'); %#4:sth*(R*A'+A*R)
lmiterm([lmiPL32 3 3 Ck2],sth*B2,1,'s');%#4:sth*(Ck'*B2'+B2*Ck)
lmiterm([lmiPL32 4 3 Ak2],sth,1); %#4:sth*(Ak)
lmiterm([lmiPL32 3 4 0],sth*A2); %#4:sth*(A)
lmiterm([lmiPL32 3 4 Dk2],sth*B2,C2); %#4:sth*(B2*Dk*C2)
lmiterm([lmiPL32 4 4 S],1,sth*A2,'s'); %#4:sth*(A'*S+S*A)
lmiterm([lmiPL32 4 4 Bk2],1,sth*C2,'s');%#4:sth*(C2'*Bk'+Bk*C2)
%=====
posX=-newlmi;
lmiterm([posX 1 1 R],1,1); %#5:R
lmiterm([posX 2 1 0],1); %#5:I
lmiterm([posX 2 2 S],1,1); %#5:S
%-----
lmiDk1=-newlmi;
lmiterm([lmiDk1 1 1 0],1e2); %#6:1e2
lmiterm([lmiDk1 2 2 0],1e2); %#6:1e2
lmiterm([lmiDk1 2 1 Dk1],1,1); %#6:Dk
%-----
lmiDk2=-newlmi;
lmiterm([lmiDk2 1 1 0],1e2); %#6:1e2
lmiterm([lmiDk2 2 2 0],1e2); %#6:1e2
lmiterm([lmiDk2 2 1 Dk2],1,1); %#6:Dk
%-----
lmig=newlmi;
lmiterm([lmig,1,1,gam],1,1); %#7:gam
lmiterm([lmig,1,1,0],-1e3); %#7:1e3
LMIs=getlmis;
end
%-----
%eof
|