正在加载图片...
Drawnow命令迫使 MATLAB更新屏幕,只要 MATLAB回到命令提示,或执行dr ure, getframe或 pause命令,屏幕就更新。 drawnow的特殊形式 draunow(' discard')使事件 队列中所有事件的放弃。在回调中将 drawnow(’ discard’)包含在一个特殊命令之前,就含有 清除事件队列的效果,防止刷新事件,以及回调事件中断回调。 21.8M文件举例 精通 MATLAB工具箱中一些函数阐明了上面所讨论的若干技术。第一个例子 mmview3d应 用全局变量和递归函数调用,把方位角和仰角滑标加到图形中。函数中有大量的对象,但函数 很直观。因为 mmview3d文件相当得长,故分段表示。第一段定义了函数标号,帮助文本和全 局变量 MMVIe3d GUI controlled Azimuth and Elevation adustment for adjusting azimuth and elevation using the mouse % The 'Revert pushbutton reverts to the original view The cmd argument executes the callback Copyright(c)1996 by Prentice-Hall, Inc global Hc acur Hc esli Hc ecur CVIEW 第二段处理初始用户的调用,建立必要的 uncontrol对象并把回调定义为递归函数调用 %o Assign a handle to the current f window Get the current view for slider values Use normalized uncontrol units rather than the default ' pixel Hf fig=gcf CVIEW=get(gca,'View); if abs(CVIEW(I))180, CVIEW(1)=CVIEW(1)-(360*sign(CVIEW(I)): end set(Hf fig, 'DefaultUicontrolUnits','normalized ' Define azimuth and elevation sliders The position is in normalized units(0-1) Maximum, minimum, and initial values are set He asli-uicontrol(Hf fig,'style,slider position',[.09.02.3.05], CVIEW(I), callback,'mmview3d(991));Drawnow命令迫使MATLAB更新屏幕,只要MATLAB回到命令提示,或执行drawnow, figure,getframe或pause命令,屏幕就更新。drawnow的特殊形式draunow( ' discard ' )使事件 队列中所有事件的放弃。在回调中将drawnow( ' discard ' )包含在一个特殊命令之前,就含有 清除事件队列的效果,防止刷新事件,以及回调事件中断回调。 21.8 M文件举例 精通MATLAB工具箱中一些函数阐明了上面所讨论的若干技术。第一个例子mmview3d应 用全局变量和递归函数调用,把方位角和仰角滑标加到图形中。函数中有大量的对象,但函数 很直观。因为mmview3d文件相当得长,故分段表示。第一段定义了函数标号,帮助文本和全 局变量。 function mmview3d(cmd) % MMVIE3D GUI controllled Azimuth and Elevation adustment. % for adjusting azimuth and elevation using the mouse. % % The ' Revert ' pushbutton reverts to the original view. % The ' cmd ' argument executes the callbacks. % Copyright (c) 1996 by Prentice-Hall, Inc. global Hc_acur Hc_esli Hc_ecur CVIEW 第二段处理初始用户的调用,建立必要的uicontrol对象并把回调定义为递归函数调用。 if nargin==0 %------------------------------------------------------------------ % Assign a handle to the current figure window. % Get the current view for slider initial values. % Use normalized uicontrol units rather than the default ' pixels ' . %------------------------------------------------------------------ Hf_fig=gcf; CVIEW=get(gca, ' View ' ); if abs(CVIEW(1))>180, CVIEW(1)=CVIEW(1)-(360*sign(CVIEW(1)));end set(Hf_fig, ' DefaultUicontrolUnits ' , ' normalized ' ); %------------------------------------------------------------------- % Define azimuth and elevation sliders. % The position is in normalized units (0-1). % Maximum, minimum, and initial values are set. %-------------------------------------------------------------------- Hc_asli=uicontrol(Hf_fig, ' style ' , ' slider ' ,... ' position ' ,[.09 .02 .3 .05],... ' min ' ,-180, ' max ' ,180, ' value ' , CVIEW(1),... ' callback ' , ' mmview3d(991) ' );
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有