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

📄 imcmenu.m

📁 Software for design and tuninig of SISO and MIMO contol systems
💻 M
📖 第 1 页 / 共 5 页
字号:
switch IMENU
case 1000
      if not_save_yet
      temp=questdlg('File has been changed, save it now?');
      if strcmp(temp,'Yes')
   		if ~strcmp(NAMEFILE,'untitled.mat')
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      		eval(Command);
   		else
   			cd(datadir); 
   			[temp,temp1]=uiputfile('*.mat','Save As');
   			cd(cwdir);
   			if all(temp) & all(temp1)
      			NAMEFILE=temp;
      			datadir=temp1;
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      			eval(Command);
   			end
         end
      end
      not_save_yet=0;
   end
   delete(main_fig);   

case 1100 % New File
   if not_save_yet
      temp=questdlg('File has been changed, save it now?');
      if strcmp(temp,'Yes')
   		if ~strcmp(NAMEFILE,'untitled.mat')
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      		eval(Command);
   		else
   			cd(datadir); 
   			[temp,temp1]=uiputfile('*.mat','Save As');
   			cd(cwdir);
   			if all(temp) & all(temp1)
      			NAMEFILE=temp;
      			datadir=temp1;
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      			eval(Command);
   			end
         end
      end
      not_save_yet=0;
   end
   close(main_fig);
%   clear global
	imctune   
case 1200 % Load
   if not_save_yet
      temp=questdlg('File has been changed, save it now?');
      if strcmp(temp,'Yes')
   		if ~strcmp(NAMEFILE,'untitled.mat')
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      		eval(Command);
   		else
   			cd(datadir); 
   			[temp,temp1]=uiputfile('*.mat','Save As');
   			cd(cwdir);
   			if all(temp) & all(temp1)
      			NAMEFILE=temp;
      			datadir=temp1;
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      			eval(Command);
   			end
         end
      end
   end
   cd(datadir); 
   [temp,temp1]=uigetfile('*.mat','Select and open a file');
   cd(cwdir);
   if all(temp) & all(temp1)
      NAMEFILE=temp;
      datadir=temp1;
      Command=['load ',datadir,NAMEFILE,' '];
      
      % Try to convert the old global variable to the local variable
      %-----------------------------------
      tmp2=cascade;
      clear Epsilon d_through_p cascade
      %clear global
      eval(Command);
      set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE ']']);
      if isglobal(Epsilon)|isglobal(d_through_p)
         set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
         not_save_yet=1;
	      temp=Epsilon;
         if exist('d_through_p') & ~isempty(d_through_p)
            temp1=d_through_p;
         else
            temp1=0;
         end
         tmp=Xwc_ub_w;tmp1=Xwc_lb_w;
         clear global
         global Xwc_ub_w Xwc_lb_w
         Xwc_ub_w=tmp; Xwc_lb_w=tmp1; 
   	   Epsilon=temp; d_through_p=temp1;
      end
      if ~exist('cascade')
         cascade=tmp2;
      end
      clear tmp tmp1 tmp2
      %---------------------------------
      temp=length(Tcanc);
      if temp<5
         Tcanc=[zeros(2,5-temp) Tcanc];
      end
      if exist('pnums')
         convertdata1 % convert the old single loop system data to new data format
         not_save_yet=1;
      set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
      elseif cascade & exist('cdenc')
         convertdata2 % convert the old cascade system data to new data format
			not_save_yet=1;
      set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
      elseif exist('Xpnums') & exist('cdenc')
         convertdata2 
         not_save_yet=1;
      set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE '*]']);
      end
      if cascade
         set(MAIN_MENU(15),'Value',3);
      elseif degree_freedom==2
         set(MAIN_MENU(15),'Value',2);
      else
         set(MAIN_MENU(15),'Value',1);
      end
      [maxrow,maxcol,n_of_TF,temp]=size(Xpnums);
		set(MAIN_MENU(14),'Value',maxrow);
		set(MAIN_MENU(16),'Value',maxcol);
		set(MAIN_MENU(18),'Value',n_of_TF);
      p_unstable=0; % reset the conditional variable
      for i=1:maxrow
      for j=1:maxcol
      for l=1:cascade+1
      for k=1:n_of_TF
         [Xpnummt{i,j,k,l},Xunidn{i,j,k,l}]=ms2mtx1(Xpnums{i,j,k,l});
         [Xpdenmt{i,j,k,l},Xunidd{i,j,k,l}]=ms2mtx1(Xpdens{i,j,k,l});
         [Xpdeadmt{i,j,k,l},Xuniddt{i,j,k,l}]=ms2mtx1(Xpdeads{i,j,k,l});
         [Xmnummt{i,j,k,l},Xmunidn{i,j,k,l}]=ms2mtx1(Xmnums{i,j,k,l});
         [Xmdenmt{i,j,k,l},Xmunidd{i,j,k,l}]=ms2mtx1(Xmdens{i,j,k,l});
         %set the conditional variable of unstable system
         if Xmdenmt{i,j,k,l} & any(roots(mt2poly(Xmdenmt{i,j,k,l},y)) > 0)
            p_unstable=1;
         end
         [Xmdeadmt{i,j,k,l},Xmuniddt{i,j,k,l}]=ms2mtx1(Xmdeads{i,j,k,l});
      end;end;
         [Xpdnummt{i,j},Xpdunidn{i,j}]=ms2mtx1(Xpdnums{i,j});
         [Xpddenmt{i,j},Xpdunidd{i,j}]=ms2mtx1(Xpddens{i,j});
      end;end
   if exist('satub')==1
      satubs=num2str(satub);
      satlbs=num2str(satlb);
      clear satub satlb
   end
		Satub=str2num(satubs);
		Satlb=str2num(satlbs);

      [p_umax,Xpnummt,Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt]=cnt_uncM(Xpnummt,...
         Xpdenmt,Xpdeadmt,Xpdnummt,Xpddenmt,Xunidn,Xunidd,Xuniddt,Xpdunidn,Xpdunidd);
      [m_umax,Xmnummt,Xmdenmt,Xmdeadmt]=cnt_uncM(Xmnummt,Xmdenmt,Xmdeadmt,...
         Xmunidn,Xmunidd,Xmuniddt);
      chn_sys_dim;
      JMENU=2; cback;
      for i=1:maxrow
      for j=1:maxcol
      for l=1:cascade+1
      for k=1:n_of_TF
            [Xpnum{i,j,k,l}]=mtx2str(Xpnummt{i,j,k,l},1);
            [Xpden{i,j,k,l}]=mtx2str(Xpdenmt{i,j,k,l},1);
            [Xpdead{i,j,k,l}]=mtx2str(Xpdeadmt{i,j,k,l},3);
            [Xmnum{i,j,k,l}]=mtx2str(Xmnummt{i,j,k,l},2);
   			[Xmden{i,j,k,l}]=mtx2str(Xmdenmt{i,j,k,l},2);
   			[Xmdead{i,j,k,l}]=mtx2str(Xmdeadmt{i,j,k,l},4);
            if k==1
               if ~strcmp(Xpden{i,j,k,l},'')
                  temp=['(' Xpden{i,j,k,l} ')'];
                  if strcmp(Xpdead{i,j,k,l},'')
                     p{i,j,l}=[Xpnum{i,j,k,l} '/' temp];
                  else
                     p{i,j,l}=[Xpnum{i,j,k,l} '/' temp '*' Xpdead{i,j,k,l}];
                  end
               else
                  if strcmp(Xpdead{i,j,k,l},'')
                     p{i,j,l}=Xpnum{i,j,k,l};
                  else
                     p{i,j,l}=[Xpnum{i,j,k,l} '*' Xpdead{i,j,k,l}];
                  end
               end
               if ~strcmp(Xmden{i,j,k,l},'')
                  temp=['(' Xmden{i,j,k,l} ')'];
                  if strcmp(Xmdead{i,j,k,l},'')
                     m{i,j,l}=[Xmnum{i,j,k,l} '/' temp];
                  else
                     m{i,j,l}=[Xmnum{i,j,k,l} '/' temp '*' Xmdead{i,j,k,l}];
                  end
               else
                  if strcmp(Xmdead{i,j,k,l},'')
                     m{i,j,l}=Xmnum{i,j,k,l};
                  else
                     m{i,j,l}=[Xmnum{i,j,k,l} '*' Xmdead{i,j,k,l}];
                  end
               end
            else
               p{i,j,l}=multi_tf(i,j,Xpnum,Xpden,Xpdead,l);
               m{i,j,l}=multi_tf(i,j,Xmnum,Xmden,Xmdead,l);
            end
            if l==1
               temp=maxcol*(i-1)+j;
               set(diag_handle(temp),'TooltipString',p{i,j,l});
            	temp=maxrow*maxcol+maxcol*(i-1)+j;
            	set(diag_handle(temp),'TooltipString',m{i,j,l});
            else
               temp=2*maxrow*maxcol+maxcol*(i-1)+j;
               set(diag_handle(temp),'TooltipString',p{i,j,l});
            	temp=3*maxrow*maxcol+maxcol*(i-1)+j;
            	set(diag_handle(temp),'TooltipString',m{i,j,l});
            end
         end % k
      end % l
         [Xpdnum{i,j}]=mtx2str(Xpdnummt{i,j},1);
         [Xpdden{i,j}]=mtx2str(Xpddenmt{i,j},1);
         if cascade
         	[Xpdden{i,j}]=mtx2str(Xpdenmt{i,j,1,1},1);
            if strcmp(Xpden{i,j,1},'')
               pd{i,j}='1';
            else
               temp=['(' Xpden{i,j,1} ')'];
               pd{i,j}=['1/' temp]; 
            end              
         else
            if strcmp(Xpdden{i,j},'')
               pd{i,j}=Xpdnum{i,j};
            else
               temp=['(' Xpdden{i,j} ')'];
               pd{i,j}=[Xpdnum{i,j} '/' temp]; 
            end              
            if ~(d_through_p | cascade)
               temp=2*maxrow*maxcol+maxcol*(i-1)+j;
               set(diag_handle(temp),'TooltipString',pd{i,j});
            end
         end
      end % i
   end % j

      uindex=get_uindex(Xpnummt,Xpdenmt,Xpdeadmt);
      muindex=get_uindex(Xmnummt,Xmdenmt,Xmdeadmt);
      pduindex=get_uindex(Xpdnummt,Xpddenmt);
      IMENU=3100; imcmenu;
      
   end % if all(temp) & all(temp1)
   
case 1300 %save File
   if ~strcmp(NAMEFILE,'untitled.mat')
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      eval(Command);
      not_save_yet=0;
   set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE ']']);
   else
   	cd(datadir); 
   	[temp,temp1]=uiputfile('*.mat','Save As');
   	cd(cwdir);
   if all(temp) & all(temp1)
      	NAMEFILE=temp;
      	datadir=temp1;
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      	eval(Command);
      not_save_yet=0;
      set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE ']']);
   	end
   end
   
case 1400
   cd(datadir); 
   [temp,temp1]=uiputfile('*.mat','Save As');
   cd(cwdir);
   if all(temp) & all(temp1)
      NAMEFILE=temp;
      datadir=temp1;
            if maxrow >1 | maxcol > 1
               Command=['save ',datadir,NAMEFILE,' ',Var3save];
            else
               if cascade
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               elseif degree_freedom==2
                  Command=['save ',datadir,NAMEFILE,' ',Var2save];
               else
                  Command=['save ',datadir,NAMEFILE,' ',Varsave];
               end
            end
      eval(Command);
      not_save_yet=0;
      set(main_fig,'Name',['Internal Model Control Tuning - [' datadir NAMEFILE ']']);
   end
   
case 2600    % Saturation Bound
[f]=crfig(50,50,350,150,'Saturation Bounds','w','none','off');
uicontrol(f,...
 'Style','text',...
 'Position',[20 120 80 18],...

⌨️ 快捷键说明

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