MATLAB |
%cADIP_of_gs.m
%-----
clear all, close all
global ell1 ell2 th10 th20
ell1=0.13; ell2=0.15; m1=0.05; m2=0.03; g=9.8;
Ta=0.1; Ka=1;
th10=0; th20=0;
th1=0; th2=70/180*pi;
rymax=2*ell1*cos(th1); rymin=2*ell1*cos(th2); rynom=rymax;
rxmin=2*ell1*sin(th1); rxmax=2*ell1*sin(th2); rxnom=rxmax;
A0=[0 1 0 0;
3*g/(4*ell2) 0 -3*g/(4*ell2) 0;
0 0 0 0;
0 0 0 -1/Ta];
A1=[0 0 0 0;
0 0 0 0;
0 0 0 1;
0 0 0 0];
Amax=A0+rymax*A1;
Amin=A0+rymin*A1;
Anom=A0+rynom*A1;
B=[0;0;0;Ka/Ta];
CM=[1 0 0 0;
0 0 1 0];
DM=[0;0];
S0=[A0 B;CM DM];
S1=[A1 zeros(4,1);zeros(2,5)];
%-----
wD=0.02; wI=0.5; C0=CM(2,:);
AA1=[Amin zeros(4,1);-C0 0];
AA2=[Amax zeros(4,1);-C0 0];
B1=[zeros(4,1);1]; B2=[B;0];
C1=[zeros(1,4) wI;wD*C0*Anom 0]; D11=zeros(2,1); D12=[0;wD*C0*B];
C2=[CM zeros(2,1);zeros(1,4) 1]; D21=[0;0;0]; D22=[0;0;0];
%=====
alpha=0.1; r=50; th=90/180*pi;
LMIs=of_synlmi7(AA1,AA2,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(AA1,1))-R*S);
sd=diag(sqrt(1./diag(sd)));
Ni=sd*v'; Mti=u*sd;
AK1=Ni*(ak1-S*(AA1-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];
%-----
pl1=eig(AA1)
ACL1=[AA1+B2*DK1*C2 B2*CK1;
BK1*C2 AK1];
plCL1=eig(ACL1)
figure(1)
dregion(-alpha,0,r,th,r*[-1,1,-1,1])
plot(real(pl1),imag(pl1),'x',real(plCL1),imag(plCL1),'*')
%-----
ACL1=[AA1+B2*DK1*C2 B2*CK1;BK1*C2 AK1];
BCL1=[B1+B2*DK1*D21;BK1*D21];
CCL1=[C2(1,:) zeros(1,5)];
AK1=[AK1 BK1(:,3);zeros(1,6)];
BK1=[BK1(:,1:2) zeros(5,1); -1 0 1];
CK1=[CK1 DK1(:,3)];
DK1=[DK1(:,1:2) 0];
SK1=[AK1 BK1;CK1 DK1];
%-----
w=logspace(-2,2,100);
ga_WS=20*log10(abs(wI./(i*w)));
ga_WT=20*log10(abs(wD*(i*w)));
G(:,:)=freqresp(ss(Amax,B,C0,[]),w); G=G.'; ga_G=20*log10(abs(G));
K(:,:)=freqresp(ss(AK1,BK1(:,1),CK1,DK1(:,1)),w); K=K.'; ga_K=20*log10(abs(K));
T(:,:)=freqresp(ss(ACL1,BCL1(:,1),CCL1(1,:),[]),w); T=T.'; ga_T=20*log10(abs(T));
ga_S=20*log10(abs(1-T));
figure(2)
subplot(121),semilogx(w,ga_G+ga_K,w,ga_WS,'b',w,-ga_WT,'r'),grid,legend('L','WS','1/WT')
subplot(122),semilogx(w,ga_T,'r',w,-ga_WT,'r',w,ga_S,'b',w,-ga_WS,'b'),grid,legend('T','1/WT','S','1/WS')
%=====
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(AA2,1))-R*S);
sd=diag(sqrt(1./diag(sd)));
Ni=sd*v'; Mti=u*sd;
AK2=Ni*(ak2-S*(AA2-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];
%-----
pl2=eig(AA2)
ACL2=[AA2+B2*DK2*C2 B2*CK2;
BK2*C2 AK2];
plCL2=eig(ACL2)
figure(3)
dregion(-alpha,0,r,th,r*[-1,1,-1,1])
plot(real(pl2),imag(pl2),'x',real(plCL2),imag(plCL2),'*')
%-----
ACL2=[AA2+B2*DK2*C2 B2*CK2;BK2*C2 AK2];
BCL2=[B1+B2*DK2*D21;BK2*D21];
CCL2=[C2(1,:) zeros(1,5)];
AK2=[AK2 BK2(:,3);zeros(1,6)];
BK2=[BK2(:,1:2) zeros(5,1); -1 0 1];
CK2=[CK2 DK2(:,3)];
DK2=[DK2(:,1:2) 0];
SK2=[AK2 BK2;CK2 DK2];
%-----
w=logspace(-2,2,100);
ga_WS=20*log10(abs(wI./(i*w)));
ga_WT=20*log10(abs(wD*(i*w)));
G(:,:)=freqresp(ss(Amin,B,C0,[]),w); G=G.'; ga_G=20*log10(abs(G));
K(:,:)=freqresp(ss(AK2,BK2(:,1),CK2,DK2(:,1)),w); K=K.'; ga_K=20*log10(abs(K));
T(:,:)=freqresp(ss(ACL2,BCL2(:,1),CCL2(1,:),[]),w); T=T.'; ga_T=20*log10(abs(T));
ga_S=20*log10(abs(1-T));
figure(4)
subplot(121),semilogx(w,ga_G+ga_K,w,ga_WS,'b',w,-ga_WT,'r'),grid,legend('L','WS','1/WT')
subplot(122),semilogx(w,ga_T,'r',w,-ga_WT,'r',w,ga_S,'b',w,-ga_WS,'b'),grid,legend('T','1/WT','S','1/WS')
%-----
prange=rymax-rymin; pmax=rymax; pmin=rymin;
%sim("ADIP_of_gs")
sim("ADIP_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
|