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

📄 plot_proc.m

📁 很优良的PID控制器设计仿真程序与模型,经过严格检验
💻 M
📖 第 1 页 / 共 2 页
字号:

%----------------------------------------------------------------
%curv_proc is used to change properties of a user selected curve.
%
%  curv_proc(nTask,nStyle)
%where 
%  nTask -- curve manipulation code
%        1 for delete curve, 2 for change colour
%        3-6 for different line styles
%        {7,8,9,10,11,12} for different marks
%        13-14 for line width
%        15 for save as EPS files
%----------------------------------------------------------------
function curv_proc(nTask)

%get the handle of a curve
if nTask==20, hG=legd_proc(0,6); %select all 
elseif nTask<=14, hG=legd_proc(0,5); else, hG=1; end

if length(hG)>0
   %if such a handle exists, then process it
   switch nTask
   case 1, delete(hG); %delete current curve
   case 2, %get a new color and set the color of it
      nColor=uisetcolor;
      if length(nColor)==3, set(hG,'Color',nColor); end
   case {3,4,5,6} %set line styles of the curve
      ii=26:29; i=find(ii~=nTask+23); extra_funs(4,1,'Checked',nTask+23,ii(i));
      switch nTask
      case 3, nStyle='-';
      case 4, nStyle='--';
      case 5, nStyle=':';
      case 6, nStyle='-.';
      end, 
      set(hG,'LineStyle',nStyle);   
   case {7,8,9,10,11,12} %set markers of the curve
      ii=31:35; i=find(ii~=nTask+24); extra_funs(4,1,'Checked',nTask+24,ii(i));
      switch nTask
      case 7, nStyle='*';
      case 8, nStyle='+';
      case 9, nStyle='o';
      case 10, nStyle='x';
      case 11, nStyle='.';
      case 12, nStyle='none';   
      end, 
      set(hG,'Marker',nStyle);   
   case {13,14}
      h_Width=get(hG,'LineWidth');
      if nTask==13, kk=2; else, kk=0.5; end
      set(hG,'LineWidth',kk*h_Width);
   case {15,16,17,18,19}
      %save the figure to Encaptulated PS file
      graf_tool(3,1); g_graf=gcf;
      switch nTask
      case {15,16}
         u_prompt='*.eps'; uu=get(gcf,'UserData'); 
         if length(uu)>=5, u_prompt=[uu{5},u_prompt]; end
         [filename,filepath]=uiputfile(u_prompt,'Please Specify the an EPF File Name');
         if ~isa(filename,'double')
            uu{6}=[filepath,filename]; uu{5}=filepath; str=uu{6}; set(gcf,'UserData',uu);
            if nTask==15, eval(['print(''-deps2'', ''-adobecset'', ''' str ''');']); 
            else, eval(['print(''-deps2c'', ''-adobecset'', ''' str ''');']); end   
         end      
      case 17, print -dmeta;
      case 18, print -dbitmap;   
      case 19, [a,b]=printopt; eval(['print ' b]) %print figure on current printer   
      end
      figure(g_graf); graf_tool(3,[]);
   case 20, delete(hG); %delete current curve
   case 21, delete(hG); %delete current curve
   end
end

%----------------------------------------------------------------
%zoom_proc is used to implement zoom facilities.
%
%  zoom_proc(nTask)
%where 
%  nTask -- curve manipulation code
%        1 for zooming on/off
%        2 for x axis zoom on/off
%        3 for y axis zoom on/off
%        4 for full axis mode
%----------------------------------------------------------------
function zoom_proc(nTask)

%find the list of all existing axes on the current window
uu=get(gcf,'UserData'); g_axes=extra_funs(2,'axes');

switch nTask
case {1,2,3,4}
   b_zooms=findobj(gcf,'Tag','Toolz'); b_zooms=b_zooms(end:-1:1);
   ii=[17:20]; i1=find(ii~=nTask+16); extra_funs(4,1,'Checked',nTask+16,ii(i1)); 
   if length(b_zooms)>0, set(b_zooms,'Value',0); end
   if length(b_zooms)>0
      set(b_zooms,'Value',0); if nTask<=3, set(b_zooms(nTask),'Value',1); end
   end   
   for i=1:length(g_axes),
      switch nTask
      case 1, axes(g_axes(i)); zoom on; %set full zooming facilities
      case 2, axes(g_axes(i)); zoom xon; %set zooming facilities on x axis
      case 3, axes(g_axes(i)); zoom yon; %set zooming facilities on y axis
      case 4,   
         %automatic selecting axis ranges based on data
         set(g_axes(i),'XLimMode','auto','YLimMode','auto'); zoom off
      end      
   end   
case 5
   %display a zoom changing dialog box
   hAxis=gca;
   hAxisSet=figure('Units','normalized','Position',[0.1863 0.198 0.4375 0.333],...
      'NumberTitle','off','Name','Axis Range Select',...
      'MenuBar','none','Color',0.8*[1,1,1],'Resize','off','Tag','CtrlLABExtras');
   extra_funs(1); extra_funs(10,[0.1,0.93],[0.75,0.52]);
   uicontrol('Style','Text','String','X Axis','BackgroundColor',0.8*[1,1,1],...
      'Units','normalized','Position',[0.05 0.70 0.12 0.1]);
   [x,h(1)]=display_str(0.22,0.59,'Lower',[0,0,0],'off',9);
   [x,h(3)]=display_str(0.46,0.59,'Upper',[0,0,0],'off',9);
   h(2)=uicontrol('Style','Edit','String','','Visible','off',...
      'Units','normalized','Position',[0.34 0.54 0.1 0.1],...
      'HorizontalAlignment','left','BackgroundColor',[1,1,1]);
   h(4)=uicontrol('Style','Edit','String','','Visible','off',...
      'Units','normalized','Position',[0.58 0.54 0.1 0.1],...
      'HorizontalAlignment','left','BackgroundColor',[1,1,1]);
   [v,d]=version; v1=eval(v(1)); v2=eval(v(3)); v3=eval(v(5));
   if v2==2 & v3==0, strRadio='ToggleButton'; else, strRadio='RadioButton'; end 
   bXAxis(1)=uicontrol('Style',strRadio,'String','Current','Value',1,...
      'Units','normalized','Position',[0.22,0.79,0.22,0.1],...
      'BackgroundColor',0.8*[1,1,1],'CallBack','plot_proc(6,0,0);');
   bXAxis(2)=uicontrol('Style',strRadio,'String','Define','Value',0,...
      'Units','normalized','Position',[0.22,0.66,0.22,0.1],...
      'BackgroundColor',0.8*[1,1,1],'CallBack','plot_proc(7,0,0);');

   extra_funs(10,[0.1,0.45],[0.75,0.04]);
   uicontrol('Style','Text','String','Y Axis','BackgroundColor',0.8*[1,1,1],...
      'Units','normalized','Position',[0.05 0.20 0.12 0.1]);
   [x,h(5)]=display_str(0.22,0.14,'Lower',[0,0,0],'off',9);
   [x,h(7)]=display_str(0.46,0.14,'Upper',[0,0,0],'off',9);
   h(6)=uicontrol('Style','Edit','String','',...
      'Units','normalized','Position',[0.35 0.08 0.1 0.1],...
      'HorizontalAlignment','left','BackgroundColor',[1,1,1],'Visible','off');
   h(8)=uicontrol('Style','Edit','String','',...
      'Units','normalized','Position',[0.58 0.08 0.1 0.1],...
      'HorizontalAlignment','left','BackgroundColor',[1,1,1],'Visible','off');
   bYAxis(1)=uicontrol('Style',strRadio,'String','Current','Value',1,...
      'Units','normalized','Position',[0.22,0.32,0.22,0.1],...
      'BackgroundColor',0.8*[1,1,1],'CallBack','plot_proc(8,0,0);');
   bYAxis(2)=uicontrol('Style',strRadio,'String','Define','Value',0,...
      'Units','normalized','Position',[0.22,0.19,0.22,0.1],...
      'BackgroundColor',0.8*[1,1,1],'CallBack','plot_proc(9,0,0);');
   uicontrol('Style','Pushbutton','String','OK',...
      'Units','normalized','Position',[0.80,0.8,0.17,0.12],...
      'BackgroundColor',0.8*[1,1,1],'CallBack','plot_proc(10,0,0);');
   uicontrol('Style','Pushbutton','String','Cancel',...
      'Units','normalized','Position',[0.80,0.65,0.17,0.12],...
      'BackgroundColor',0.8*[1,1,1],'CallBack','close(gcf);');
   uicontrol('Style','Pushbutton','String','Help',...
      'Units','normalized','Position',[0.80,0.50,0.17,0.12],...
      'BackgroundColor',0.8*[1,1,1],'CallBack','clab_help(20);');
   set(gcf,'UserData',{h,bXAxis,bYAxis,hAxis});
case 6
   h=uu{1}; bXAxis=uu{2}; kk=get(bXAxis(1),'Value');
   set(bXAxis(2),'Value',~kk); set(h(1:4),'Visible',extra_funs(6,~kk));
case 7
   h=uu{1}; bXAxis=uu{2}; kk=get(bXAxis(2),'Value');
   set(bXAxis(1),'Value',~kk); set(h(1:4),'Visible',extra_funs(6,kk));
   if kk==1,
      xL=get(uu{4},'XLim'); set(h(2),'String',num2str(xL(1)));
      set(h(4),'String',num2str(xL(2)));
   end; 
case 8
   h=uu{1}; bYAxis=uu{3}; kk=get(bYAxis(1),'Value');
   set(h(5:8),'Visible',extra_funs(6,~kk)); set(bYAxis(2),'Value',~kk);
case 9
   h=uu{1}; bYAxis=uu{3}; kk=get(bYAxis(2),'Value');
   set(h(5:8),'Visible',extra_funs(6,kk)); set(bYAxis(1),'Value',~kk);
   if kk==1,
      yL=get(uu{4},'YLim'); set(h(6),'String',num2str(yL(1))); set(h(8),'String',num2str(yL(2)));
   end
case 10
   h=uu{1}; bXAxis=uu{2}; bYAxis=uu{3}; hAxis=uu{4};
   if get(bXAxis(2),'Value')==1,
      %if x axis range specified, change it
      x1=eval(get(h(2),'String')); x2=eval(get(h(4),'String')); set(hAxis,'XLim',[x1,x2]);
   end,
   if get(bYAxis(2),'Value')==1,
      %if y axis range specified, change it
      y1=eval(get(h(6),'String')); y2=eval(get(h(8),'String')); set(hAxis,'YLim',[y1,y2]);
   end
   close(gcf);
end      

⌨️ 快捷键说明

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