📄 cbackm.m
字号:
set(handle(13),'String',Xmdead{row,col,2,p_index});
set(handle(20),'String',multi_tf(row,col,Xmnum,Xmden,Xmdead,p_index));
end
case (8 + 3200)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
set(current_obj,'BackgroundColor',192/255*[1 1 1]);
qnums{row,col,TF_index,p_index}=get(gcbo,'String');
[qnummt{row,col,TF_index,p_index},qunidn{row,col,TF_index,p_index}]=ms2mtx1(qnums{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
[qnum{j,i,k,l}]=mtx2str(qnummt{j,i,k,l},2);
[qden{j,i,k,l}]=mtx2str(qdenmt{j,i,k,l},2);
[qdead{j,i,k,l}]=mtx2str(qdeadmt{j,i,k,l},4);
end;end;end;end
set(handle(11),'String',qnum{row,col,1,p_index});
set(handle(10),'String',qden{row,col,1,p_index});
set(handle(9),'String',qdead{row,col,1,p_index});
case (6 + 2200)
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
Xmdens{row,col,TF_index,p_index}=temp;
[Xmdenmt{row,col,TF_index,p_index},Xmunidd{row,col,TF_index,p_index}]=ms2mtx1(Xmdens{row,col,TF_index,p_index});
[m_umax,Xmnummt,Xmdenmt,Xmdeadmt]=cnt_uncM(Xmnummt,Xmdenmt,Xmdeadmt,Xmunidn,Xmunidd,Xmuniddt);
%set the conditional variable of unstable
if maxcol==1
if any(roots(mt2poly(Xmdenmt{row,col,TF_index,p_index},y)) > 0)
p_unstable=1;
else
p_unstable=0;
end
end
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});
set(handle(13),'String',Xmdead{row,col,2,p_index});
set(handle(20),'String',multi_tf(row,col,Xmnum,Xmden,Xmdead,p_index));
end
case (6 + 3200)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
qdens{row,col,TF_index,p_index}=get(gcbo,'String');
[qdenmt{row,col,TF_index,p_index},qunidd{row,col,TF_index,p_index}]=ms2mtx1(qdens{row,col,TF_index,p_index});
%[m_umax,Xmnummt,Xmdenmt,Xmdeadmt]=cnt_uncM(Xmnummt,Xmdenmt,Xmdeadmt,Xmunidn,Xmunidd,Xmuniddt);
%set the conditional variable of unstable
if any(roots(mt2poly(qdenmt{row,col,TF_index,p_index},y)) > 0)
p_unstable=1;
else
p_unstable=0;
end
for l=1:cascade+1
for j=1:maxrow
for i=1:maxcol
for k=1:n_of_TF
[qnum{j,i,k,l}]=mtx2str(qnummt{j,i,k,l},2);
[qden{j,i,k,l}]=mtx2str(qdenmt{j,i,k,l},2);
[qdead{j,i,k,l}]=mtx2str(qdeadmt{j,i,k,l},4);
end;end;end;end
set(handle(11),'String',qnum{row,col,1,p_index});
set(handle(10),'String',qden{row,col,1,p_index});
set(handle(9),'String',qdead{row,col,1,p_index});
case (6 + 3210)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
pd_prime{row,col}=str2num(get(gcbo,'String'));
pd_prime_str{row,col}=['1/' mtx2str(pd_prime{row,col},1)];
set(handle(7),'String',mtx2str(pd_prime{row,col},1));
set(PD_handle(maxcol*(row-1)+col),'tooltipstring',pd_prime_str{row,col});
case (3 + 3210)
close
for i=1:maxcol
temp=mq_gen(1,1,dec_M(i),1,1,order(i),y);
[qd{i,i},qdnum{i,i},qdden{i,i}]=qd_mat(pd_prime{i,i},temp,Epsilon{2}(i),order(i),y);
temp=strrep(qd{i,i},'e',num2str(Epsilon{2}(i)));
qd{i,i}=strrep(qd{i,i},'e',['e(' num2str(i) ')']);
set(QD_handle(maxcol*(i-1)+i),'tooltipstring',temp);
end
case (4 + 2200)
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
Xmdeads{row,col,TF_index,p_index}=temp;
[Xmdeadmt{row,col,TF_index,p_index},Xmuniddt{row,col,TF_index,p_index}]=ms2mtx1(Xmdeads{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});
set(handle(13),'String',Xmdead{row,col,2,p_index});
set(handle(20),'String',multi_tf(row,col,Xmnum,Xmden,Xmdead,p_index));
end
case (3 + 2200)
for i=1:maxrow
for j=1:maxcol
if ~strcmp(Xmden{i,j,1,p_index},'')
temp=['(' Xmden{i,j,1,p_index} ')'];
if strcmp(Xmdead{i,j,1,p_index},'')
m{i,j,p_index}=[Xmnum{i,j,1,p_index} '/' temp];
else
m{i,j,p_index}=[Xmnum{i,j,1,p_index} '/' temp '*' Xmdead{i,j,1,p_index}];
end
else
if strcmp(Xmdead{i,j,1,p_index},'')
m{i,j,p_index}=Xmnum{i,j,1,p_index};
else
m{i,j,p_index}=[Xmnum{i,j,1,p_index} '*' Xmdead{i,j,1,p_index}];
end
end
if p_index==1
temp=maxrow*maxcol+maxcol*(i-1)+j;
else
temp=3*maxrow*maxcol+maxcol*(i-1)+j;
end
set(diag_handle(temp),'TooltipString',m{i,j,p_index});
end
end
close;
case (3 + 3200)
temp1=zeros(maxrow,maxcol);
for i=1:maxrow
for j=1:maxcol
temp1(i,j)=length(mt2poly(qdenmt{i,j,1,1},y))-length(mt2poly(qnummt{i,j,1,1},y));
qdead{i,j,1,1}=mtx2str(qdeadmt{i,j,1,1},3);
qdeads{i,j,1,1}=num2str(qdeadmt{i,j,1,1},3);
if ~strcmp(qden{i,j,1,1},'')
temp=['(' qden{i,j,1,1} ')'];
if strcmp(qdead{i,j,1,1},'')
q{i,j,1}=[qnum{i,j,1,1} '/' temp];
else
q{i,j,1}=[qnum{i,j,1,1} '/' temp '*' qdead{i,j,1,1}];
end
else
if strcmp(qdead{i,j,1,1},'')
q{i,j,1}=qnum{i,j,1,1};
else
q{i,j,1}=[qnum{i,j,1,1} '*' qdead{i,j,1,1}];
end
end
temp=maxcol*(i-1)+j;
set(M_handle(temp),'TooltipString',q{i,j,1});
end
end
order=max(temp1');
set(order_handle,'string',num2str(order));
close
case (2 + 2200)
for i=1:maxrow
for j=1:maxcol
m{i,j,p_index}=multi_tf(i,j,Xmnum,Xmden,Xmdead,p_index);
if p_index==1
temp=maxrow*maxcol+maxcol*(i-1)+j;
else
temp=3*maxrow*maxcol+maxcol*(i-1)+j;
end
set(diag_handle(temp),'TooltipString',m{i,j,p_index});
end
end
close;
%Single loop forward path controller
%Sigle degree of freedom
case (8 + 2300)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
set(current_obj,'BackgroundColor',192/255*[1 1 1]);
qnums{row,col}=get(handle(8),'String');
[qnummt{row,col}]=ms2mtx1(qnums{row,col});
[m_umax,qnummt,qdenmt]=cnt_uncM(qnummt,qdenmt,{0},{0});
[qnum{row,col}]=mtx2str(qnummt{row,col},2);
[qden{row,col}]=mtx2str(qdenmt{row,col},2);
if strcmp(qnum{row,col},'1')
if order{row,col} > 1
qdenc{row,col}=['(e*s+1)^' num2str(order{row,col})];
elseif order{row,col}==1
qdenc{row,col}=['(e*s+1)'];
else
qdenc{row,col}=qnum{row,col};
end
else
if order{row,col} > 1
qdenc{row,col}=[qnum{row,col} '*(e*s+1)^' num2str(order{row,col})];
elseif order{row,col}==1
qdenc{row,col}=[qnum{row,col} '*(e*s+1)'];
else
qdenc{row,col}=qnum{row,col};
end
end
k=0;
[rowc,colc]=size(qnummt{row,col});
for i=1:rowc
if max(real(roots(qnummt{row,col}(i,:)))) > 0
k=1;
end
end
if k==1
warndlg('The IMC controller will be unstable.','Warning')
end
temp=strrep(qdenc{row,col},'e',num2str(Epsilon{row,col}(1)));
set(handle(10),'String',temp);
case (6 + 2300)
qdens{row,col}=get(handle(6),'String');
[qdenmt{row,col}]=ms2mtx1(qdens{row,col});
[m_umax,qnummt,qdenmt]=cnt_uncM(qnummt,qdenmt,{0},{0});
[qnum{row,col}]=mtx2str(qnummt{row,col},2);
[qden{row,col}]=mtx2str(qdenmt{row,col},2);
set(handle(11),'String',qden{row,col});
case (4 + 2300)
order{row,col}=str2num(get(handle(4),'String'));
if strcmp(qnum{row,col},'1')
if order{row,col} > 1
qdenc{row,col}=['(e*s+1)^' num2str(order{row,col})];
elseif order{row,col}==1
qdenc{row,col}=['(e*s+1)'];
else
qdenc{row,col}=qnum{row,col};
end
else
if order{row,col} > 1
qdenc{row,col}=[qnum{row,col} '*(e*s+1)^' num2str(order{row,col})];
elseif order{row,col}==1
qdenc{row,col}=[qnum{row,col} '*(e*s+1)'];
else
qdenc=qnum{row,col};
end
end
temp=strrep(qdenc{row,col},'e',num2str(Epsilon{row,col}(1)));
set(handle(10),'String',temp);
case (12 + 2300)
temp=get(handle(12),'String');
temp=ms2mtx1(temp);
if min(temp) < 0;
errordlg('Filter t.c. must be positive.');
else
Epsilon{row,col}(1)=temp;
end
temp=strrep(qdenc{row,col},'e',num2str(Epsilon{row,col}(1)));
set(handle(10),'String',temp);
case (3 + 2300)
if maxrow >1
Epsilon{1}=str2num(get(E_handle,'String'));
order=str2num(get(order_handle,'String'));
if length(order) < maxcol | length(Epsilon{1}) < maxcol
errordlg('Size of the order or the filter time constant mismatch!');
else
close;
clear E_handle order_handle
if degree_freedom==1
[Ksp,K,Kdelay,Kspstr,Kstr,Ds,Dstr]=msfgainM(q,order,Epsilon{1},qdeadmt,qnummt,qdenmt,y);
delete(diag_handle(ishandle(diag_handle))); [diag_handle]=showmsf1dfdiag(main_fig,...
maxrow,maxcol,p,pd,m,Kspstr,d_through_p,input_delay,Kstr,Dstr);
view_MIMO_MSF;
else
if any(iscellempty(diag(pd_prime)))
warndlg('Next, you need to config the feedback controller!');
else
[Ksp,K,Kdelay,Kspstr,Kstr,Ds,Dstr]=msfgainM(q,order,Epsilon{2},qdeadmt,qnummt,qdenmt,y);
delete(diag_handle(ishandle(diag_handle))); [diag_handle]=showmsf2dfdiag(main_fig,...
maxrow,maxcol,p,pd,m,Kspstr,d_through_p,input_delay,Kstr,Dstr,qd,...
prefilcal(Epsilon,order,order),Epsilon);
view_MIMO_MSF;
end
end
end
else
temp=['(' qdenc{row,col} ')'];
if strcmp(qnum{row,col},'') | strcmp(qden{row,col},'')
q{row,col}='';
else
q{row,col}=[qden{row,col} '/' temp];
end
close
end
%-----------------
% Process Lag , Pd
%-----------------
case (1 + 2400)
temp=get(handle(1),'String');
if any(isletter(temp))
errordlg('Not a number !');
else
temp=str2num(temp);
if length(temp)==length(pduindex{row,col})
vlb(pduindex{row,col})=temp;
else
errordlg('Size of bound does not match !');
end
end
case (3 + 2400)
temp=get(handle(3),'String');
if any(isletter(temp))
errordlg('Not a number !');
else
temp=str2num(temp);
if length(temp)==length(pduindex{row,col})
vub(pduindex{row,col})=temp;
else
errordlg('Size of bound does not match !');
end
end
case (12 + 2400)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
set(current_obj,'BackgroundColor',192/255*[1 1 1]);
Xpdnums{row,col}=get(handle(12),'String');
[Xpdnummt{row,col},Xpdunidn{row,col}]=ms2mtx1(Xpdnums{row,col});
[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
[Xpnum{j,i}]=mtx2str(Xpnummt{j,i},1);
[Xpden{j,i}]=mtx2str(Xpdenmt{j,i},1);
[Xpdead{j,i}]=mtx2str(Xpdeadmt{j,i},3);
[Xpdnum{j,i}]=mtx2str(Xpdnummt{j,i},1);
[Xpdden{j,i}]=mtx2str(Xpddenmt{j,i},1);
if (j~=row) | (i~=col)
if ~isempty(uindex{j,i}) & all(length(vub) >= uindex{j,i})
vub([temp{j,i}])=temp2(1,[uindex{j,i}]);
vlb([temp{j,i}])=temp2(2,[uindex{j,i}]);
end
if ~isempty(pduindex{j,i}) & all(length(vub) >= pduindex{j,i})
vub([temp1{j,i}])=temp2(1,[pduindex{j,i}]);
vlb([temp1{j,i}])=temp2(2,[pduindex{j,i}]);
end
end
end
end
uindex=temp;pduindex=temp1;
set(handle(16),'String',['Only x [ ' num2str(pduindex{row,col}) ' ] required']);
set(handle(15),'String',Xpdnum{row,col});
set(handle(14),'String',Xpdden{row,col});
case (10 + 2400)
not_save_yet=1;
set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
Xpddens{row,col}=get(handle(10),'String');
[Xpddenmt{row,col},Xpdunidd{row,col}]=ms2mtx1(Xpddens{row,col});
[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
[Xpnum{j,i}]=mtx2str(Xpnummt{j,i},1);
[Xpden{j,i}]=mtx2str(Xpdenmt{j,i},1);
[Xpdead{j,i}]=mtx2str(Xpdeadmt{j,i},3);
[Xpdnum{j,i}]=mtx2str(Xpdnummt{j,i},1);
[Xpdden{j,i}]=mtx2str(Xpddenmt{j,i},1);
if (j~=row) | (i~=col)
if ~isempty(uindex{j,i}) & all(length(vub) >= uindex{j,i})
vub([temp{j,i}])=temp2(1,[uindex{j,i}]);
vlb([temp{j,i}])=temp2(2,[uindex{j,i}]);
end
if ~isempty(pduindex{j,i}) & all(length(vub) >= pduindex{j,i})
vub([temp1{j,i}])=temp2(1,[pduindex{j,i}]);
vlb([temp1{j,i}])=temp2(2,[pduindex{j,i}]);
end
end
end
end
uindex=temp;pduindex=temp1;
set(handle(16),'String',['Only x [ ' num2str(pduindex{row,col}) ' ] required']);
set(handle(15),'String',Xpdnum{row,col});
set(handle(14),'String',Xpdden{row,col});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -