⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cback.m

📁 内模控制器(IMC)工具箱。包括参数整定、PID控制器参数转换等
💻 M
📖 第 1 页 / 共 3 页
字号:
         qf{1,1},qd{1,1},Tcanc,d_through_p,qnums{1,1},qdens{1,1});
      set(MAIN_MENU(19),'Value',d_through_p); JMENU=6; cback;
   end
   
case 5200
% PID controller with simulation
% ------------------
	switch get(MAIN_MENU(15),'Value')
	case 1 % 1Df
      pid1df_sim(1,Xpnummt,Xpdenmt,Xpdeadmt,Xmnummt,Xmdenmt,Xmdeadmt,Xpdnummt,Xpddenmt,...
         qnummt{1,1},qdenmt{1,1},order{1,1},x,y,Epsilon{1,1}(1),satubs,satlbs,d_through_p,n_of_TF);
   case 2 % 2Df
      [d_through_p]=pid2df_sim(1,Xpnummt,Xpdenmt,Xpdeadmt,Xmnummt,Xmdenmt,Xmdeadmt,...
         Xpdnummt{1,1},Xpddenmt{1,1},qnummt{1,1},qdenmt{1,1},qfnummt{1,1},...
         qfdenmt{1,1},order{1,1},F_order{1,1},x,y,Epsilon{1,1},satubs,satlbs,m{1,1},...
         qf{1,1},qd{1,1},Tcanc,d_through_p,n_of_TF);
      set(MAIN_MENU(19),'Value',d_through_p); JMENU=6; cback;
   case 3
      pid_cascade(1,Xpnummt,Xpdenmt,Xpdeadmt,Xmnummt,Xmdenmt,Xmdeadmt,...
         Xpdnummt{1,1},Xpddenmt{1,1},qnummt{1,1},qdenmt{1,1},qfnummt{1,1},...
         qfdenmt{1,1},order{1,1},F_order{1,1},x,y,Epsilon{1,1},satubs,satlbs,m,...
         qf{1,1},qd{1,1},Tcanc,d_through_p,n_of_TF);
	   if exist('diag_handle') & all(ishandle(diag_handle))
   		delete(diag_handle);
   	end
      diag_handle=showCascade2(main_fig,maxrow,maxcol,Xpnummt,Xpdnummt,...
         Xmnummt,qnummt,qfnummt);
   end
   
case 5300
      pid_cascade2(1,Xpnummt,Xpdenmt,Xpdeadmt,Xmnummt,Xmdenmt,Xmdeadmt,...
         Xpdnummt{1,1},Xpddenmt{1,1},qnummt{1,1},qdenmt{1,1},qfnummt{1,1},...
         qfdenmt{1,1},order{1,1},F_order{1,1},x,y,Epsilon{1,1},satubs,satlbs,m,...
         qf{1,1},qd{1,1},Tcanc,d_through_p,n_of_TF);
	   if exist('diag_handle') & all(ishandle(diag_handle))
   		delete(diag_handle);
   	end
      diag_handle=showCascade3(main_fig,maxrow,maxcol,Xpnummt,Xpdnummt,...
         Xmnummt,qnummt,qfnummt);
   
   
% Frequency response upper bound, lower boumd and both.
% ---------------------------------------------------------
case {4700,4710,4720,4800,4810,4820,4830,4840,4850,4900,4910,4920,...
      4930,4940,4950}
   switch JMENU
   case {4700,4710,4720} % complementary sensitivity
      if degree_freedom==1
         fun='imc1com';
         Epsilon{1,1}=Epsilon{1,1}(1);
         qf={'1'};
         temp1=p{1,1};
         temp2=m{1,1};
         if n_of_TF>1
            [mq]=mq_gen(Xmnummt,Xmdenmt,Xmdeadmt,qnummt{1},...
               qdenmt{1},order{1},y);
         else
            [mq]=mq_gen(Xmnummt{1,1},Xmdenmt{1,1},Xmdeadmt{1,1},qnummt{1},...
               qdenmt{1},order{1},y);
         end
         
      else
         if cascade
            fun='Usercas';
	         temp1=strvcat(p{1,1,1},p{1,1,2});
   	      temp2=strvcat(m{1,1,1},m{1,1,2});
            if n_of_TF>1
               [mq]=mq_gen(Xmnummt(1,1,:,2),Xmdenmt(1,1,:,2),Xmdeadmt(1,1,:,2),...
                  qfnummt{1},qfdenmt{1},F_order{1},y);
            else
               [mq]=mq_gen(Xmnummt{1,1,1,2},Xmdenmt{1,1,1,2},Xmdeadmt{1,1,1,2},...
                  qfnummt{1},qfdenmt{1},F_order{1},y);
            end
            
         else
            fun='imc2com';
	         temp1=p{1,1};
   	      temp2=m{1,1};
            if n_of_TF>1
               [mq]=mq_gen(Xmnummt,Xmdenmt,Xmdeadmt,qfnummt{1},...
                  qfdenmt{1},F_order{1},y);
            else
               [mq]=mq_gen(Xmnummt{1,1},Xmdenmt{1,1},Xmdeadmt{1,1},qfnummt{1},...
                  qfdenmt{1},F_order{1},y);
            end
            
         end
         if length(Epsilon{1,1}) < 2
            Epsilon{1,1}(2)=Epsilon{1,1}(1);
         end
      end
      temp=['complementary sensitivity function when Epsilon = ',num2str(Epsilon{1,1})];
   case {4800,4810,4820} % Sensitivity
      if degree_freedom==1
         fun='imc1sen';
         Epsilon{1,1}=Epsilon{1,1}(1);
         qf={'1'};
         if n_of_TF>1
            [mq]=mq_gen(Xmnummt,Xmdenmt,Xmdeadmt,qnummt{1},...
               qdenmt{1},order{1},y);
         else
            [mq]=mq_gen(Xmnummt{1,1},Xmdenmt{1,1},Xmdeadmt{1,1},qnummt{1},...
               qdenmt{1},order{1},y);
         end
         
      else
         fun='imc2sen';
         if cascade
	         temp1=p{1,1,2};
            temp2=m{1,1,2};
            if n_of_TF>1
               [mq]=mq_gen(Xmnummt(1,1,:,2),Xmdenmt(1,1,:,2),Xmdeadmt(1,1,:,2),...
                  qfnummt{1},qfdenmt{1},F_order{1},y);
            else
               [mq]=mq_gen(Xmnummt{1,1,1,2},Xmdenmt{1,1,1,2},Xmdeadmt{1,1,1,2},...
                  qfnummt{1},qfdenmt{1},F_order{1},y);
            end
            
         else
	         temp1=p{1,1,1};
   	      temp2=m{1,1,1};
            if n_of_TF>1
               [mq]=mq_gen(Xmnummt,Xmdenmt,Xmdeadmt,qfnummt{1},...
                  qfdenmt{1},F_order{1},y);
            else
               [mq]=mq_gen(Xmnummt{1,1},Xmdenmt{1,1},Xmdeadmt{1,1},qfnummt{1},...
                  qfdenmt{1},F_order{1},y);
            end
            
         end
         if length(Epsilon{1,1}) < 2
            Epsilon{1,1}(2)=Epsilon{1,1}(1);
         end
      end      
      temp=['sensitivity function when Epsilon = ',num2str(Epsilon{1,1})];
   case {4830,4840,4850} % partial sensitivity
      fun='imc2pseudo';
      if cascade
         temp1=p{1,1,2};
         temp2=m{1,1,2};
         if n_of_TF>1
            [mq]=mq_gen(Xmnummt(1,1,:,2),Xmdenmt(1,1,:,2),Xmdeadmt(1,1,:,2),...
               qfnummt{1},qfdenmt{1},F_order{1},y);
         else
            [mq]=mq_gen(Xmnummt{1,1,1,2},Xmdenmt{1,1,1,2},Xmdeadmt{1,1,1,2},...
               qfnummt{1},qfdenmt{1},F_order{1},y);
         end
      else
         temp1=p{1,1,1};
         temp2=m{1,1,1};
         if n_of_TF>1
            [mq]=mq_gen(Xmnummt,Xmdenmt,Xmdeadmt,qfnummt{1},...
               qfdenmt{1},F_order{1},y);
         else
            [mq]=mq_gen(Xmnummt{1,1},Xmdenmt{1,1},Xmdeadmt{1,1},qfnummt{1},...
               qfdenmt{1},F_order{1},y);
         end
         
      end
      if length(Epsilon{1,1}) < 2
         Epsilon{1,1}(2)=Epsilon{1,1}(1);
      end
      temp=['partial sensitivity function when Epsilon = ',num2str(Epsilon{1,1})];
   case {4900,4910,4920} % Integrated Sensitivity function
      fun='int2sen1';
      if cascade
         temp1=p{1,1,2};
         temp2=m{1,1,2};
         if n_of_TF>1
            [mq]=mq_gen(Xmnummt(1,1,:,2),Xmdenmt(1,1,:,2),Xmdeadmt(1,1,:,2),...
               qfnummt{1},qfdenmt{1},F_order{1},y);
         else
            [mq]=mq_gen(Xmnummt{1,1,1,2},Xmdenmt{1,1,1,2},Xmdeadmt{1,1,1,2},...
               qfnummt{1},qfdenmt{1},F_order{1},y);
         end
      else
         temp1=p{1,1,1};
         temp2=m{1,1,1};
         if n_of_TF>1
            [mq]=mq_gen(Xmnummt,Xmdenmt,Xmdeadmt,qfnummt{1},...
               qfdenmt{1},F_order{1},y);
         else
            [mq]=mq_gen(Xmnummt{1,1},Xmdenmt{1,1},Xmdeadmt{1,1},qfnummt{1},...
               qfdenmt{1},F_order{1},y);
         end
      end
      if length(Epsilon{1,1}) < 2
         Epsilon{1,1}(2)=Epsilon{1,1}(1);
      end
      temp=['Integrated sensitivity function when Epsilon = ',num2str(Epsilon{1,1})];
   case {4930,4940,4950} % Normallized Integrated Sensitivity function
      fun='int2sen';
      if cascade
         temp1=p{1,1,2};
         temp2=m{1,1,2};
         if n_of_TF>1
            [mq]=mq_gen(Xmnummt(1,1,:,2),Xmdenmt(1,1,:,2),Xmdeadmt(1,1,:,2),...
               qfnummt{1},qfdenmt{1},F_order{1},y);
         else
            [mq]=mq_gen(Xmnummt{1,1,1,2},Xmdenmt{1,1,1,2},Xmdeadmt{1,1,1,2},...
               qfnummt{1},qfdenmt{1},F_order{1},y);
         end
      else
         temp1=p{1,1,1};
         temp2=m{1,1,1};
         if n_of_TF>1
            [mq]=mq_gen(Xmnummt,Xmdenmt,Xmdeadmt,qfnummt{1},...
               qfdenmt{1},F_order{1},y);
         else
            [mq]=mq_gen(Xmnummt{1,1},Xmdenmt{1,1},Xmdeadmt{1,1},qfnummt{1},...
               qfdenmt{1},F_order{1},y);
         end
         
      end
      if length(Epsilon{1,1}) < 2
         Epsilon{1,1}(2)=Epsilon{1,1}(1);
      end
      temp=['Normallized Integrated sensitivity function when Epsilon = ',num2str(Epsilon{1,1})];
   end
   clflag=1;
   clmap=[1,0,0;1,1,0;1,0,1;0,0,1;1,1,1];
   if isempty(x) | length(x)~=length(vub)
      x=(vub+vlb)/2;
   end
   switch JMENU
   case {4700,4800,4830,4900,4930}
      fprintf('                      Upper bound calculations \n\n');
         [Results,refreq]=optfunf(Epsilon{1,1},fun,decade,numpdec,vub,vlb,x,y,-1,temp1,temp2,...
            q{1,1},qf{1,1},qd{1,1},pd{1,1},Mp,0,Acc,Tcanc,F_order{1},mq);
      Results
      f=crfig(3,5,634,410,'Upper bound of frequency response','k','figure','on');
		colordef black;
      freq = Results(:,1)'; upb = Results(:,2)'; 
      if strcmp(fun,'imc1com') | strcmp(fun,'imc2com')
         loglog(freq, upb, '-b', refreq, [Mp(1) Mp(1)], '--w')
      else
         if length(Mp)==1
            Mp(2)=Mp(1);
         end
         loglog(freq, upb, '-b', refreq, [Mp(2) Mp(2)], '--w')
      end
      title(['Upper bound of ',temp]);
   case {4710,4810,4840,4910,4940}
      fprintf('                      Lower bound calculations \n\n');
         [Results,refreq]=optfunf(Epsilon{1,1},fun,decade,numpdec,vub,vlb,x,y,1,...
            temp1,temp2,q{1,1},qf{1,1},qd{1,1},pd{1,1},Mp,0,Acc,Tcanc,F_order{1},mq);
      Results
      f=crfig(3,5,633,410,'Lower bound of frequency response','k','figure','on');
		colordef black;
      freq = Results(:,1)'; lwb = Results(:,2)';
      if strcmp(fun,'imc1com') | strcmp(fun,'imc2com')
         loglog(freq, lwb, '-m', refreq, [Mp(1) Mp(1)], '--w')
      else
         if length(Mp)==1
            Mp(2)=Mp(1);
         end
         loglog(freq, lwb, '-m', refreq, [Mp(2) Mp(2)], '--w')
      end
      title(['Lower bound of ',temp]);
      
   case {4720,4820,4850,4920,4950}
      fprintf('                      Upper bound calculations \n\n');
         [Results,refreq]=optfunf(Epsilon{1,1},fun,decade,numpdec,vub,vlb,x,y,-1,temp1,temp2,...
            q{1,1},qf{1,1},qd{1,1},pd{1,1},Mp,0,Acc,Tcanc,F_order{1},mq);
      Results
      freq = Results(:,1)'; 
      upb = Results(:,2)'; disp(' ');
      fprintf('                      Lower bound calculations \n\n');
         [Results,refreq]=optfunf(Epsilon{1,1},fun,decade,numpdec,vub,vlb,x,y,1,...
            temp1,temp2,q{1,1},qf{1,1},qd{1,1},pd{1,1},Mp,0,Acc,Tcanc,F_order{1},mq);
      Results
      lwb = Results(:,2)';
      f=crfig(3,5,634,410,'Upper & Lower bound of frequency response','k','figure','on');
		colordef black;
      if strcmp(fun,'imc1com') | strcmp(fun,'imc2com')
         loglog(freq, upb, '-b',freq, lwb, '-.m', refreq, [Mp(1) Mp(1)], '--w')
      else
         if length(Mp)==1
            Mp(2)=Mp(1);
         end
         loglog(freq, upb, '-b',freq, lwb, '-.m', refreq, [Mp(2) Mp(2)], '--w')
      end
      title(['Upper & Lower bound of ',temp]);
   end
   xlabel('Frequency (rad/unit time)'); ylabel('Magnitude'); grid off;
   coord
%  colordef black;
uicontrol(f,...
  'Style','push',...
  'Position',[575 350 55 30],...
  'String','Add',...
  'Callback',['JMENU=10001;','cback']);
uicontrol(f,...
  'Style','push',...
  'Position',[575 300 55 30],...
  'String','Close',...
  'Callback','close');
uicontrol(f,...
  'Style','push',...
  'Position',[575 250 55 30],...
  'String','Help',...
  'Callback','sayhelp(IMENU)');


case 10001 %  Add a frequency response of a plant
   if length(x)~=length(vub)
      x=(vub+vlb)/2;
   end
f=crfig(5,200,300,211,'Change parameters','w','none','off');
uicontrol(f,... 
'Style','text',...
'Position',[75 170 150 18],...
'Backgroundcolor','w',...
'Foregroundcolor','k',...
'HorizontalAlignment','Left',...
'String','Uncertain parameters:');
uicontrol(f,... 
'Style','text',...
'Position',[20 130 260 18],...
'Backgroundcolor','w',...
'Foregroundcolor','k',...
'HorizontalAlignment','Left',...
'String','Enter the values of x(1), x(2), ...');
uicontrol(f,...
'Style','frame',...
'Position',[20 97 260 24],...
'Backgroundcolor','w',...
'Foregroundcolor','k');
temp='';
for i=1:length(x);
 temp=[temp num2str(x(i)) ' '];
end
uicontrol(f,...
'Style','edit',...
'Position',[25 100 250 18],...
'Backgroundcolor','w',...
'Foregroundcolor','k',...
'String',temp,...
'Callback',['x=str2num(get(gcbo,''String''));']);
uicontrol(f,...
'Style','push',...
'Position',[110 20 80 25],...
'String','OK',...
'Callback',['if length(x)==length(vlb) & all(x<=vub) & all(x>=vlb) close; bode_unc;',...
'else errordlg(''size of x does not match, or infeasible''); end']);

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -