最简单的方法之一是使用findobj。
这会查看图形对象,找到与提供的过滤条件匹配的对象。
由于现有数字的数量应该相对较少,因此也应该相当快。
假设您的启动器图形有一些名称,您可以获得启动器图形句柄
例如通过
launcherFig = findobj(0,'type','figure', 'name', <launcher-name>);
或者给你的 lauchner 人物一个Tag,你可以搜索:
% in your launcher-figure code:
launcherFig = figure('Tag', 'MyLauncher');
% and modify the search accordingly:
launcherFig = findobj(0, 'type', 'figure', 'Tag', 'MyLauncher');
而且,为了完整起见,虽然我不喜欢它们,但您可以使用 global 变量:
% in your launcher-figure code:
launcherFig = figure(...);
% store handle in the global variable:
global LauncherHandle;
LauncherHandle = launcherFig;
% no need for a search now anymore, just get the global variable:
global LauncherHandle