如related answer中所述,可以使用以下方式获取所有未结数字的句柄:
hFigs = findall(groot, 'Type', 'figure');
但这导致列表包含" old" figure
和" new" uifigure
处理。
如何将hFigs
分成两个列表,一个仅包含 figure
,另一个仅 uifigure
个引用?< / p>
答案 0 :(得分:2)
要以编程方式区分figure
和uifigure
个对象,我们可以稍微调整一下我的建议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上测试该溶液。