📄 cbackm.m
字号:
handle=get(gcf,'Child');
temp=get(gcf,'UserData');
row=temp{1}(1); col=temp{1}(2);p_index=temp{1}(3);
current_obj=temp{2};
IMENU=get(current_obj,'UserData');
JMENU=get(gcbo,'UserData')+IMENU;
switch JMENU
case (1 + 2100)
temp=get(gcbo,'String');
if any(isletter(temp))
errordlg('Not a number !');
else
temp=str2num(temp);
if isempty(temp)
vlb(uindex{row,col,p_index})=[];
elseif length(temp)==length(uindex{row,col,p_index})
vlb(uindex{row,col,p_index})=temp;
else
errordlg('Size of bound does not match !');
end
end
case (3 + 2100)
temp=get(gcbo,'String');
if any(isletter(temp))
errordlg('Not a number !');
else
temp=str2num(temp);
if isempty(temp)
vub(uindex{row,col,p_index})=[];
elseif length(temp)==length(uindex{row,col,p_index})
vub(uindex{row,col,p_index})=temp;
else
errordlg('Size of bound does not match !');
end
end
case (14 + 2100)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
set(current_obj,'BackgroundColor',192/255*[1 1 1]);
temp=get(gcbo,'String');
if any(isletter(temp)) & ~all(temp(find(isletter(temp)))=='u')
errordlg('Syntax error! Only numerical values and a letter ''u'' are allowed. (See user manual).');
return
end
Xpnums{row,col,TF_index,p_index}=temp;
[Xpnummt{row,col,TF_index,p_index},Xunidn{row,col,TF_index,p_index}]=ms2mtx1(Xpnums{row,col,TF_index,p_index});
[p_umax,Xpnummt,Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt]=cnt_uncM(Xpnummt,...
Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt,Xunidn,Xunidd,Xuniddt,Xpdunidn,Xpdunidd);
temp=get_uindex(Xpnummt,Xpdenmt,Xpdeadmt);
temp1=get_uindex(Xpdnummt,Xpddenmt);
temp2=[vub;vlb]; % save the original bounds
for j=1:maxrow
for i=1:maxcol
for l=1:cascade+1;
for k=1:n_of_TF
[Xpnum{j,i,k,l}]=mtx2str(Xpnummt{j,i,k,l},1);
[Xpden{j,i,k,l}]=mtx2str(Xpdenmt{j,i,k,l},1);
[Xpdead{j,i,k,l}]=mtx2str(Xpdeadmt{j,i,k,l},3);
end
if (j~=row) | (i~=col)
if ~isempty(uindex{j,i,l}) & all(length(vub) >= uindex{j,i,l})
vub([temp{j,i,l}])=temp2(1,[uindex{j,i,l}]);
vlb([temp{j,i,l}])=temp2(2,[uindex{j,i,l}]);
end
if l==1 & ~isempty(pduindex{j,i,l}) & all(length(vub) >= pduindex{j,i,l})
vub([temp1{j,i,l}])=temp2(1,[pduindex{j,i,l}]);
vlb([temp1{j,i,l}])=temp2(2,[pduindex{j,i,l}]);
end
end
end
[Xpdnum{j,i}]=mtx2str(Xpdnummt{j,i},1);
[Xpdden{j,i}]=mtx2str(Xpddenmt{j,i},1);
end
end
uindex=temp;pduindex=temp1;
set(handle(19),'String',['Only x [ ' num2str(uindex{row,col,p_index}) ' ] required']);
set(handle(18),'String',Xpnum{row,col,1,p_index});
set(handle(17),'String',Xpden{row,col,1,p_index});
set(handle(16),'String',Xpdead{row,col,1,p_index});
if n_of_TF==2
set(handle(22),'String',Xpnum{row,col,2,p_index});
set(handle(21),'String',Xpden{row,col,2,p_index});
set(handle(20),'String',Xpdead{row,col,2,p_index});
set(handle(23),'String',multi_tf(row,col,Xpnum,Xpden,Xpdead,p_index));
end
case (12+2100)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
temp=get(gcbo,'String');
if any(isletter(temp)) & ~all(temp(find(isletter(temp)))=='u')
errordlg('Syntax error! Only numerical values and a letter ''u'' are allowed. (See user manual).');
return
end
Xpdens{row,col,TF_index,p_index}=temp;
[Xpdenmt{row,col,TF_index,p_index},Xunidd{row,col,TF_index,p_index}]=ms2mtx1(Xpdens{row,col,TF_index,p_index});
[p_umax,Xpnummt,Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt]=cnt_uncM(Xpnummt,...
Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt,Xunidn,Xunidd,Xuniddt,Xpdunidn,Xpdunidd);
temp=get_uindex(Xpnummt,Xpdenmt,Xpdeadmt);
temp1=get_uindex(Xpdnummt,Xpddenmt);
temp2=[vub;vlb]; % save the original bounds
for j=1:maxrow
for i=1:maxcol
for l=1:cascade+1;
for k=1:n_of_TF
[Xpnum{j,i,k,l}]=mtx2str(Xpnummt{j,i,k,l},1);
[Xpden{j,i,k,l}]=mtx2str(Xpdenmt{j,i,k,l},1);
[Xpdead{j,i,k,l}]=mtx2str(Xpdeadmt{j,i,k,l},3);
end
if (j~=row) | (i~=col)
if ~isempty(uindex{j,i,l}) & all(length(vub) >= uindex{j,i,l})
vub([temp{j,i,l}])=temp2(1,[uindex{j,i,l}]);
vlb([temp{j,i,l}])=temp2(2,[uindex{j,i,l}]);
end
if l==1 & ~isempty(pduindex{j,i,l}) & all(length(vub) >= pduindex{j,i,l})
vub([temp1{j,i,l}])=temp2(1,[pduindex{j,i,l}]);
vlb([temp1{j,i,l}])=temp2(2,[pduindex{j,i,l}]);
end
end
end
[Xpdnum{j,i}]=mtx2str(Xpdnummt{j,i},1);
[Xpdden{j,i}]=mtx2str(Xpddenmt{j,i},1);
end
end
uindex=temp;pduindex=temp1;
set(handle(19),'String',['Only x [ ' num2str(uindex{row,col,p_index}) ' ] required']);
set(handle(18),'String',Xpnum{row,col,1,p_index});
set(handle(17),'String',Xpden{row,col,1,p_index});
set(handle(16),'String',Xpdead{row,col,1,p_index});
if n_of_TF==2
set(handle(22),'String',Xpnum{row,col,2,p_index});
set(handle(21),'String',Xpden{row,col,2,p_index});
set(handle(20),'String',Xpdead{row,col,2,p_index});
set(handle(23),'String',multi_tf(row,col,Xpnum,Xpden,Xpdead,p_index));
end
case (10 + 2100)
not_save_yet=1; %To indicate file changed
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
temp=get(gcbo,'String');
if any(isletter(temp)) & ~all(temp(find(isletter(temp)))=='u')
errordlg('Syntax error! Only numerical values and a letter ''u'' are allowed. (See user manual).');
return
end
Xpdeads{row,col,TF_index,p_index}=temp;
[Xpdeadmt{row,col,TF_index,p_index},Xuniddt{row,col,TF_index,p_index}]=ms2mtx1(Xpdeads{row,col,TF_index,p_index});
[p_umax,Xpnummt,Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt]=cnt_uncM(Xpnummt,...
Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt,Xunidn,Xunidd,Xuniddt,Xpdunidn,Xpdunidd);
temp=get_uindex(Xpnummt,Xpdenmt,Xpdeadmt);
temp1=get_uindex(Xpdnummt,Xpddenmt);
temp2=[vub;vlb]; % save the original bounds
for j=1:maxrow
for i=1:maxcol
for l=1:cascade+1;
for k=1:n_of_TF
[Xpnum{j,i,k,l}]=mtx2str(Xpnummt{j,i,k,l},1);
[Xpden{j,i,k,l}]=mtx2str(Xpdenmt{j,i,k,l},1);
[Xpdead{j,i,k,l}]=mtx2str(Xpdeadmt{j,i,k,l},3);
end
if (j~=row) | (i~=col)
if ~isempty(uindex{j,i,l}) & all(length(vub) >= uindex{j,i,l})
vub([temp{j,i,l}])=temp2(1,[uindex{j,i,l}]);
vlb([temp{j,i,l}])=temp2(2,[uindex{j,i,l}]);
end
if l==1 & ~isempty(pduindex{j,i,l}) & all(length(vub) >= pduindex{j,i,l})
vub([temp1{j,i,l}])=temp2(1,[pduindex{j,i,l}]);
vlb([temp1{j,i,l}])=temp2(2,[pduindex{j,i,l}]);
end
end
end
[Xpdnum{j,i}]=mtx2str(Xpdnummt{j,i},1);
[Xpdden{j,i}]=mtx2str(Xpddenmt{j,i},1);
end
end
uindex=temp;pduindex=temp1;
set(handle(19),'String',['Only x [ ' num2str(uindex{row,col,p_index}) ' ] required']);
set(handle(18),'String',Xpnum{row,col,1,p_index});
set(handle(17),'String',Xpden{row,col,1,p_index});
set(handle(16),'String',Xpdead{row,col,1,p_index});
if n_of_TF==2
set(handle(22),'String',Xpnum{row,col,2,p_index});
set(handle(21),'String',Xpden{row,col,2,p_index});
set(handle(20),'String',Xpdead{row,col,2,p_index});
set(handle(23),'String',multi_tf(row,col,Xpnum,Xpden,Xpdead,p_index));
end
case (9 + 2100)
[p_umax,Xpnummt,Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt]=cnt_uncM(Xpnummt,...
Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt,Xunidn,Xunidd,Xuniddt,Xpdunidn,Xpdunidd);
temp=get(handle(1),'String');
if ~isempty(temp)
if any(isletter(temp))
errordlg('Bound is not a number!');
return
else
temp=str2num(temp);
if length(temp)==length(uindex{row,col,p_index})
vlb(uindex{row,col,p_index})=temp;
else
errordlg('Size of bound does not match !');
return
end
end
vlb=vlb(1:p_umax);
end
temp=get(handle(3),'String');
if ~isempty(temp)
if any(isletter(temp))
errordlg('Bound is not a number !');
return
else
temp=str2num(temp);
if length(temp)==length(uindex{row,col,p_index})
vub(uindex{row,col,p_index})=temp;
else
errordlg('Size of bound does not match !');
return
end
end
vub=vub(1:p_umax);
end
if any(vub<vlb)
errordlg('Bounds infeasible !');
return
end
for l=1:cascade+1
for i=1:maxrow
for j=1:maxcol
if ~strcmp(Xpden{i,j,1,l},'')
temp=['(' Xpden{i,j,1,l} ')'];
if strcmp(Xpdead{i,j,1,l},'')
p{i,j,l}=[Xpnum{i,j,1,l} '/' temp];
else
p{i,j,l}=[Xpnum{i,j,1,l} '/' temp '*' Xpdead{i,j,1,l}];
end
else
if strcmp(Xpdead{i,j,1,l},'')
p{i,j,l}=Xpnum{i,j,1,l};
else
p{i,j,l}=[Xpnum{i,j,1,l} '*' Xpdead{i,j,1,l}];
end
end
if l==1
temp=maxcol*(i-1)+j;
else
temp=2*maxrow*maxcol+maxcol*(i-1)+j;
end
set(diag_handle(temp),'TooltipString',p{i,j,l});
end
end;end
if ~d_through_p & ~cascade
for i=1:maxrow
for j=1:maxcol
if strcmp(Xpdden{i,j,1},'')
pd{i,j}=Xpdnum{i,j,1};
else
temp=['(' Xpdden{i,j,1} ')'];
pd{i,j}=[Xpdnum{i,j,1} '/' temp];
end
temp=2*maxrow*maxcol+maxcol*(i-1)+j;
set(diag_handle(temp),'TooltipString',pd{i,j});
end
end
end
if p_index==1 & cascade
for i=1:maxrow
for j=1:maxcol
[Xpdden{i,j}]=mtx2str(Xpdenmt{i,j,1,1},1);
if strcmp(Xpden{i,j,1,1},'')
pd{i,j}='1';
else
temp=['(' Xpden{i,j,1,1} ')'];
pd{i,j}=['1/' temp];
end
end
end
end
close;
case (8 + 2100)
[p_umax,Xpnummt,Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt]=cnt_uncM(Xpnummt,...
Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt,Xunidn,Xunidd,Xuniddt,Xpdunidn,Xpdunidd);
temp=get(handle(1),'String');
if ~isempty(temp)
if any(isletter(temp))
errordlg('Bound must be a number!');
return
else
temp=str2num(temp);
if length(temp)==length(uindex{row,col,p_index})
vlb(uindex{row,col,p_index})=temp;
else
errordlg('Size of bound does not match !');
return
end
end
vlb=vlb(1:p_umax);
end
temp=get(handle(3),'String');
if ~isempty(temp)
if any(isletter(temp))
errordlg('Bound must be a number !');
return
else
temp=str2num(temp);
if length(temp)==length(uindex{row,col,p_index})
vub(uindex{row,col,p_index})=temp;
else
errordlg('Size of bound does not match !');
return
end
end
vub=vub(1:p_umax);
end
if any(vub<vlb)
errordlg('Bounds infeasible !');
return
end
for l=1:cascade+1
for i=1:maxrow
for j=1:maxcol
p{i,j,l}=multi_tf(i,j,Xpnum,Xpden,Xpdead,l);
if l==1
temp=maxcol*(i-1)+j;
else
temp=2*maxrow*maxcol+maxcol*(i-1)+j;
end
set(diag_handle(temp),'TooltipString',p{i,j,l});
end
end ; end
if ~d_through_p & ~cascade
for i=1:maxrow
for j=1:maxcol
if strcmp(Xpdden{i,j,1},'')
pd{i,j}=Xpdnum{i,j,1};
else
temp=['(' Xpdden{i,j,1} ')'];
pd{i,j}=[Xpdnum{i,j,1} '/' temp];
end
temp=2*maxrow*maxcol+maxcol*(i-1)+j;
set(diag_handle(temp),'TooltipString',pd{i,j});
end
end
end
if p_index==1 & cascade
for i=1:maxrow
for j=1:maxcol
[Xpdden{i,j}]=mtx2str(Xpdenmt{i,j,1,1},1);
if strcmp(Xpden{i,j,1,1},'')
pd{i,j}='1';
else
if ~isempty(Xpden{i,j,2,1})
temp=['(' Xpden{i,j,1,1} '*' Xpden{i,j,2,1} ')'];
else
temp=['(' Xpden{i,j,1,1} ')'];
end
pd{i,j}=['1/' temp];
end
end
end
end
close;
case (18 + 2200)
mds=chn2five(get(handle(18),'String'));
set(handle(18),'String',mds);
if any(isletter(mds))
temp='Currently,lag model must be numbers. ';
temp=strvcat(temp,'Variable model will be introduced later');
errordlg(temp);
end
[temp2]=str2num(mds);
temp=length(temp2);
if temp >= 5
Tcanc(2,:)=temp2((temp-4):temp);
elseif temp == 4
Tcanc(2,1)=0;
Tcanc(2,2:5)=temp2;
elseif temp == 3
Tcanc(2,1:2)=0;
Tcanc(2,3:5)=temp2;
elseif temp == 2
Tcanc(2,1:3)=0;
Tcanc(2,4:5)=temp2;
else
Tcanc(2,:)=[0 0 0 0 1];
end
set(handle(16),'String',mtx2str(Tcanc(2,:),2));
case (8 + 2200)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
set(current_obj,'BackgroundColor',192/255*[1 1 1]);
temp=get(gcbo,'String');
if any(isletter(temp)) & ~all(temp(find(isletter(temp)))=='u')
errordlg('Syntax error! Only numerical values and a letter ''u'' are allowed. (See user manual).');
return
end
Xmnums{row,col,TF_index,p_index}=temp;
[Xmnummt{row,col,TF_index,p_index},Xmunidn{row,col,TF_index,p_index}]=ms2mtx1(Xmnums{row,col,TF_index,p_index});
[m_umax,Xmnummt,Xmdenmt,Xmdeadmt]=cnt_uncM(Xmnummt,Xmdenmt,Xmdeadmt,Xmunidn,Xmunidd,Xmuniddt);
for l=1:cascade+1
for j=1:maxrow
for i=1:maxcol
for k=1:n_of_TF
[Xmnum{j,i,k,l}]=mtx2str(Xmnummt{j,i,k,l},2);
[Xmden{j,i,k,l}]=mtx2str(Xmdenmt{j,i,k,l},2);
[Xmdead{j,i,k,l}]=mtx2str(Xmdeadmt{j,i,k,l},4);
end;end;end;end
set(handle(12),'String',Xmnum{row,col,1,p_index});
set(handle(11),'String',Xmden{row,col,1,p_index});
set(handle(10),'String',Xmdead{row,col,1,p_index});
if n_of_TF==2
set(handle(15),'String',Xmnum{row,col,2,p_index});
set(handle(14),'String',Xmden{row,col,2,p_index});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -