如何获取所有打开的 App Designer 应用程序 (uifigures) 的句柄?

How to get the handles of all open App Designer apps (uifigures)?

related answer 中所述,可以使用以下方法获取所有打开图形的句柄:

hFigs = findall(groot, 'Type', 'figure');

但这会导致列表包含 "old" figure 和 "new" uifigure 句柄。

如何将 hFigs 分成两个列表,一个包含 only figure,另一个包含 only uifigure 参考文献?

为了以编程方式区分 figureuifigure 对象,我们可以对我的建议 here:

稍作调整
function tf = isUIFigure(hFigList)
  tf = arrayfun(@(x)isstruct(struct(x).ControllerInfo), hFigList);
end

建议在调用上述方法之前关闭几个警告,例如

% Turn off warnings:
ws(2) = warning('query','MATLAB:structOnObject');
ws(1) = warning('query','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
for indW = 1:numel(ws)
  warning('off', ws(indW).identifier);
end
% Call function:
tf = isUIFigure(hFigs);
% Restore the warnings' state:
warning(ws);

总结一下:

hFigs = findall(groot, 'Type', 'figure');
isUIF = isUIFigure(hFigs);
hNewFigs = hFigs(isUIF);
hOldFigs = hFigs(~isUIF);

此解决方案已在 R2017a 和 R2017b 上进行测试。