正在加载图片...
如果是代码或字符串,开关也可以相同方式编程。 if nargin< 1, switch=0: end: if isst(switch), error(' Invalid argument), end SWI <statements to create controls or menus> <statements to implement the GUI function> elseif switch==l, <statements to perform the Call back associated with setcolor> elseif switch =2 statements to perform the Callback associated with close> 下面的例子说明了方位角滑标如何可作为单独的函数M文件来实现: function setview(switch ifr startup if -isstr(switch), error(Invalid argument. ): end vw=get(gca, 'view): This information is needed in both sections if strcmp(switch, '')% Define the controls and tag them He az= uncontrol(gcf, 'Style','slider, Position’,[10514020], Min',-90,'Max,90, 'Value'vw(1), i Tag',' AZslider Callback,'setview('set)); He min=uncontrol(gcf, Style,text Position'",[10254020] String, num2str(get(Hc az, 'Min )) He max=uncontrol(gcf,' Style,text Position',[0254020], String, num2str(get( Hc az,' Max )) He cur =uncontrol(gcf, 'Style,text Position',[60254020] Tag',' AZcur string, num2str(get(Hc az, 'Value ' )) elseif strcmp(switch,'set)% Execute the Callback He azfindobj(gcf, Tag,' AZslider'): He cur-findobj(gcf, 'Tag,'AZcur')end 如果是代码或字符串,开关也可以相同方式编程。 if nargin < 1, switch = 0; end; if isstr(switch), error( ' Invalid argument ' ), end; if switch = = 0, <statements to create controls or menus> <statements to implement the GUI function> elseif switch = =1, <statements to perform the Callback associated with setcolor> elseif switch ==2, <statements to perform the Callback associated with close> end 下面的例子说明了方位角滑标如何可作为单独的函数M文件来实现: function setview(switch) if nargin < 1, switch = ' startup ' ; end; if ~isstr(switch), error( ' Invalid argument. ' ); end; vw = get(gca, ' view ' ); % This information is needed in both sections if strcmp(switch, ' startup ' ) % Define the controls and tag them Hc_az = uicontrol(gcf, ' Style ' , ' slider ' ,... ' Position ' ,[10 5 140 20],... ' Min ' ,-90, ' Max ' ,90, ' Value ' vw(1),... ' Tag ' , ' AZslider ' ,... ' Callback ' , ' setview( ' set ' ) ' ); Hc_min=uicontrol(gcf, ' Style ' , ' text ' ,... ' Position ' ,[10 25 40 20],... ' String ' ,num2str(get(Hc_az, ' Min ' ))); Hc_max = uicontrol(gcf, ' Style ' , ' text ' ,... ' Position ' ,[110 25 40 20],... ' String ' ,num2str(get(Hc_az, ' Max ' ))); Hc_cur =uicontrol(gcf, ' Style ' , ' text ' ,... ' Position ' ,[60 25 40 20],... ' Tag ' , ' AZcur ' ,... ' string ' ,num2str(get(Hc_az, ' Value ' ))); elseif strcmp(switch, ' set ' ) % Execute the Callback Hc_az=findobj(gcf, ' Tag ' , ' AZslider ' ); Hc_cur-findobj(gcf, ' Tag ' , ' AZcur ' );
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有