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

📄 mimo_freq.m

📁 Software for design and tuninig of SISO and MIMO contol systems
💻 M
字号:
if any(iscellempty(Xmnummt)) | any(iscellempty(Xmdenmt)) | ...
      any(iscellempty(Xpnummt)) | any(iscellempty(Xpdenmt)) | ...
      any(iscellempty(qnummt)) | any(iscellempty(qdenmt))
   errordlg('Not enough data entered');
   return
end
[Xwc_ub_w,Xwc_lb_w]=init_ub_lb(decade,numpdec,vub,maxrow,maxcol);
if ~exist('COLOR_MAP')
   global COLOR_MAP
end
if degree_freedom==1
   fun='mimo1com';
else
   fun='mimo2com';
end
if exist('fig_h') & ishandle(fig_h)
   if ishandle(fig_h)
      figure(fig_h);
   end
   return
end
[fig_h]=crfig(30,30,600,600,'Frequency Response of the MIMO system',[.5 .55 .6],'figure','on');
set(fig_h,'DeleteFcn',['clear M1_handle fig_h X_handle L_handle Plot_handle B_handle ',...
      ' E1_handle Tune_index;']);
axes('position',[0.1 0.35 0.8 0.6]);
set(gca,'color',[.5 .55 .6]);
axis([0 1 0.001 1.2]);
text(.2,1,'Choose appropriate filter time constants, select I/O','color','y');
text(.2,.9,'elements (white=unselected,colored=selected), then ','color','y');
text(.2,.8,'click on either upper bound, lower bound, or both ','color','y');
text(.2,.7,'upper&lower bound icons to compute the frequency ','color','y');
text(.2,.6,'responses for the selected I/O elements.','color','y');
text(.2,.5,'You may also tune the system by guessing starting filter ','color','b');
text(.2,.4,'time constants, then clicking the Tune button.','color','b');

uicontrol('Parent',fig_h, ...
 'Style','frame',...
'Position',[2 2 125 100]);
uicontrol('Parent',fig_h, ...
 'Style','frame',...
'Position',[129 2 296 31]);
uicontrol('Parent',fig_h, ...
 'Style','frame',...
'Position',[129 35 296 67]);
uicontrol('Parent',fig_h, ...
 'Style','frame',...
'Position',[427 2 122 100]);
uicontrol('Parent',fig_h, ...
 'Style','frame',...
'Position',[2 104 150 60]);
uicontrol('Parent',fig_h, ...
 'Style','frame',...
'Position',[154 104 130 60]);
uicontrol('Parent',fig_h, ...
 'Style','frame',...
'Position',[286 104 263 60]);
uicontrol(fig_h,...
 'Style','text',...
 'Position',[160 142 100 20],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','Left',...
 'String','Magnitude Limits :');
uicontrol(fig_h,...
 'Style','text',...
 'Position',[160 125 60 20],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','Left',...
 'String','Upper limit :');
temp=axis;
L_handle(1)=uicontrol(fig_h,...
 'Style','edit',...
 'Position',[225 127 50 18],...
 'Backgroundcolor','w',...
 'HorizontalAlignment','Center',...
 'String',num2str(temp(end)),...
 'Callback','temp=axis;temp(end)=str2num(get(gcbo,''String''));axis(temp);');
uicontrol(fig_h,...
 'Style','text',...
 'Position',[160 105 60 20],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','Left',...
 'String','Lower limit :');
L_handle(2)=uicontrol(fig_h,...
 'Style','edit',...
 'Position',[225 108 50 18],...
 'Backgroundcolor','w',...
 'HorizontalAlignment','Center',...
 'String',num2str(temp(end-1)),...
 'Callback','temp=axis;temp(end-1)=str2num(get(gcbo,''String''));axis(temp);');
uicontrol(fig_h,...
 'Style','push',...
 'Position',[350 137 190 20],...
 'Backgroundcolor',[ 0 .5 .5 ],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','Left',...
 'String','Browse the upper (lower) bound results',...
 'Callback',['if ~exist(''row'')| ~exist(''col'') row=1; col=1; end; ',...
 'B_handle=browse_results(fig_h,row,col,1);'] );
uicontrol(fig_h,...
   'Style','text',...
   'Position',[290 130 50 18],...
   'HorizontalAlignment','Center',...
   'String','q~. _ .~p*');
Tune_index=1;
uicontrol('Parent',fig_h, ...
   'Position',[292 110 170 20], ...
   'Backgroundcolor','w',...
   'Foregroundcolor','k',...
   'String','Use a complete tuning|Use a step of SIMPLE tuning', ...
   'Style','popupmenu', ...
   'Tag','PopupMenu1', ...
   'Value',Tune_index,...
   'Enable','off',...
   'Callback','Tune_index=get(gcbo,''Value'');');
uicontrol(fig_h,...
 'Style','text',...
 'Position',[10 142 120 20],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','Left',...
 'String','Frequency data points :');

uicontrol(fig_h,...
 'Style','text',...
 'Position',[10 125 70 20],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','right',...
 'String','Decade :');
uicontrol(fig_h,...
 'Style','edit',...
 'Position',[85 127 60 18],...
 'Backgroundcolor','w',...
 'HorizontalAlignment','Center',...
 'String',num2str(decade),...
 'Callback',['temp=str2num(get(gcbo,''String''));',...
    'if length(temp)~=2, errordlg(''size mismatch'');',...
    'else, decade=temp;',...
 	 '[Xwc_ub_w,Xwc_lb_w]=init_ub_lb(decade,numpdec,vub,maxrow,maxcol);end']);
uicontrol(fig_h,...
 'Style','text',...
 'Position',[10 105 70 20],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','Left',...
 'String','# per decade :');
uicontrol(fig_h,...
 'Style','edit',...
 'Position',[85 108 60 18],...
 'Backgroundcolor','w',...
 'HorizontalAlignment','Center',...
 'String',num2str(numpdec),...
 'Callback',['numpdec=str2num(get(gcbo,''String''));',...
    '[Xwc_ub_w,Xwc_lb_w]=init_ub_lb(decade,numpdec,vub,maxrow,maxcol);']);
uicontrol(fig_h,...
 'Style','text',...
 'Position',[10 80 100 20],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','Left',...
 'String','I/O elements :');
if degree_freedom==1
   uicontrol(fig_h,...
      'Style','text',...
      'Position',[135 80 140 20],...
      'Foregroundcolor','k',...
      'HorizontalAlignment','Left',...
      'String','Filter time constants:');
   if length(Mp) < maxcol
      Mp(length(Mp)+1:maxcol)=Mp(1);
   end
   if length(Epsilon{1}) < maxcol
      Epsilon{1}(length(Epsilon{1})+1:maxcol)=Epsilon{1}(1);
   end
   uicontrol(fig_h,...
      'Style','text',...
      'Position',[135 57 40 20],...
      'Foregroundcolor','k',...
      'HorizontalAlignment','Left',...
      'String','e:');
   uicontrol(fig_h,...
      'Style','text',...
      'Position',[135 38 40 20],...
      'Foregroundcolor','k',...
      'HorizontalAlignment','Left',...
      'String','Mp:');
   temp=268/maxcol;
   for i=1:maxcol
      E1_handle(i)=uicontrol(fig_h,...
         'Style','edit',...
         'Position',[156+(i-1)*temp 57 temp-3 20],...
         'Backgroundcolor','w',...
         'Foregroundcolor','k',...
         'HorizontalAlignment','Center',...
         'String',num2str(Epsilon{1}(i)),...
         'Callback',['Epsilon{1}(' num2str(i), ...
            ')=str2num(get(gcbo,''string''));']);
      uicontrol(fig_h,...
         'Style','edit',...
         'Position',[156+(i-1)*temp 38 temp-3 18],...
         'Backgroundcolor','w',...
         'Foregroundcolor','k',...
         'HorizontalAlignment','Center',...
         'String',num2str(Mp(i)),...
         'Callback',['Mp(' num2str(i),...
            ')=str2num(get(gcbo,''string''));']);
   end
   uicontrol('Parent',fig_h, ...
      'Position',[140 3 170 25], ...
      'Backgroundcolor','w',...
      'Foregroundcolor','k',...
      'String','From setpoint to output|From disturbance to output', ...
      'Style','popupmenu', ...
      'Tag','PopupMenu1', ...
      'Value',1,...
      'Enable','on',...
      'Callback',['temp=get(gcbo,''Value'');if temp==2 ',...
         'fun=''mimo1sen''; else fun=''mimo1com'';end; ',...
     ' [Xwc_ub_w,Xwc_lb_w]=init_ub_lb(decade,numpdec,vub,maxrow,maxcol);']);
else
   if length(Mp) < maxcol
      Mp(length(Mp)+1:maxcol)=Mp(1);
   end
   if length(Epsilon{1}) < maxcol
      Epsilon{1}(length(Epsilon{1})+1:maxcol)=Epsilon{1}(1);
   end
   if length(Epsilon) < 2
      Epsilon(2)=Epsilon(1);
   end
   uicontrol(fig_h,...
      'Style','text',...
      'Position',[135 77 40 20],...
      'Foregroundcolor','k',...
      'HorizontalAlignment','Left',...
      'String','er');
   uicontrol(fig_h,...
      'Style','text',...
      'Position',[135 57 40 20],...
      'Foregroundcolor','k',...
      'HorizontalAlignment','Left',...
      'String','e');
   uicontrol(fig_h,...
      'Style','text',...
      'Position',[135 38 40 20],...
      'Foregroundcolor','k',...
      'HorizontalAlignment','Left',...
      'String','Mp');
   temp=268/maxcol;
   E1_handle=zeros(1,2*maxcol);
   for i=1:maxcol
      E1_handle(i)=uicontrol(fig_h,...
         'Style','edit',...
         'Position',[156+(i-1)*temp 78 temp-3 18],...
         'Backgroundcolor','w',...
         'Foregroundcolor','k',...
         'HorizontalAlignment','Center',...
         'String',num2str(Epsilon{1}(i)),...
         'Callback',['Epsilon{1}(' num2str(i), ...
            ')=str2num(get(gcbo,''string''));']);
      E1_handle(maxcol+i)=uicontrol(fig_h,...
         'Style','edit',...
         'Position',[156+(i-1)*temp 58 temp-3 18],...
         'Backgroundcolor','w',...
         'Foregroundcolor','k',...
         'HorizontalAlignment','Center',...
         'String',num2str(Epsilon{2}(i)),...
         'Callback',['Epsilon{2}(' num2str(i), ...
            ')=str2num(get(gcbo,''string''));',...
            'IMENU=3220; imcmenu;']);
      uicontrol(fig_h,...
         'Style','edit',...
         'Position',[156+(i-1)*temp 38 temp-3 18],...
         'Backgroundcolor','w',...
         'Foregroundcolor','k',...
         'HorizontalAlignment','Center',...
         'String',num2str(Mp(i)),...
         'Callback',['Mp(' num2str(i),...
            ')=str2num(get(gcbo,''string''));']);
   end
   fun_handle=uicontrol('Parent',fig_h, ...
	'Position',[140 3 170 25], ...
   'Backgroundcolor','w',...
   'Foregroundcolor','k',...
	'String','From setpoint to output|From disturbance to output|Partial sensitivity function', ...
	'Style','popupmenu', ...
	'Tag','PopupMenu1', ...
   'Value',1,...
   'Enable','on',...
   'Callback',['temp=get(gcbo,''Value'');switch temp; ',...
   'case 1, fun=''mimo2com''; pds=cell2str(pd); ',...
	'case 2, fun=''mimo2sen''; pds=cell2str(pd); ',...
   'case 3, fun=''mimopartial'';',...
   ' if strcmp(pdxs,''1'') ',...
   ' [tmp,tmp1,pds]=pdmodel(Xpdnummt,Xpddenmt,vlb);',...
	' else pds=pdxs;  end; end;',...
   ' [Xwc_ub_w,Xwc_lb_w]=init_ub_lb(decade,numpdec,vub,maxrow,maxcol);']);
end
uicontrol(fig_h,...
  'Style','push',...
  'Position',[322 7 90 21],...
  'Backgroundcolor',[ 0 .5 .5 ],...
  'String','Close Window',...
  'Callback','close; clear global Tune_flag;');

uicontrol(fig_h,...
 'Style','text',...
 'Position',[435 77 100 20],...
 'Foregroundcolor','k',...
 'HorizontalAlignment','Left',...
 'String','Compute :');
uicontrol(fig_h,...
 'Style','push',...
 'Position',[470 110 70 20],...
 'Backgroundcolor',[ 0 .5 .5 ],...
 'HorizontalAlignment','Center',...
 'String','Tune',...
 'Callback',['Epsilon=mimo_tune(fun,fig_h,Mp,y,vub,vlb,E1_handle,cell2str(p),cell2str(m),',...
    'cell2str(q),order,L_handle,input_delay,dec_M,pd_prime,pds,',...
    'M1_handle,decade,Tune_index,Acc);']);
uicontrol(fig_h,...
  'Style','push',...
  'Position',[432 54 110 20],...
  'Backgroundcolor',[ 0 .5 .5 ],...
  'String','Upper bound',...
  'Callback',['mimo_ub_lb(fun,fig_h,1,y,vub,vlb,Epsilon,cell2str(p),cell2str(m),cell2str(q),',...
     'cell2str(qd),order,M1_handle,L_handle,Plot_handle,input_delay,pds,Mp,decade);']);
uicontrol(fig_h,...
  'Style','push',...
  'Position',[432 31 110 20],...
  'Backgroundcolor',[ 0 .5 .5 ],...
  'String','Lower bound',...
  'Callback',['mimo_ub_lb(fun,fig_h,2,y,vub,vlb,Epsilon,cell2str(p),cell2str(m),cell2str(q),',...
     'cell2str(qd),order,M1_handle,L_handle,Plot_handle,input_delay,pds,Mp,decade);']);
uicontrol(fig_h,...
  'Style','push',...
  'Position',[432 8 110 20],...
  'Backgroundcolor',[ 0 .5 .5 ],...
  'String','Upper-Lower bound',...
  'Callback',['mimo_ub_lb(fun,fig_h,3,y,vub,vlb,Epsilon,cell2str(p),cell2str(m),cell2str(q),',...
     'cell2str(qd),order,M1_handle,L_handle,Plot_handle,input_delay,pds,Mp,decade);']);

M1_handle=Xuiarray([20 30 90 50],maxrow,maxcol,0,0,...
   'push','p_index=1;imcmenuM;','','',4700,fig_h);
Plot_handle=uicontrol(fig_h,...
 'Style','checkbox',...
 'Position',[20 5 100 20],...
 'HorizontalAlignment','Left',...
 'Value',0,... 
 'String','Plot new figure');
COLOR_MAP=colormap;
xlabel('Frequency');
ylabel('Magnitude');

⌨️ 快捷键说明

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