如何在 MATLAB 中获取所有打开图形的句柄 [英] How do I get the handles of all open figures in MATLAB

查看:55
本文介绍了如何在 MATLAB 中获取所有打开图形的句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 matlab 中有九个开放图形(由另一个函数生成),我想将它们全部打印到文件中.有谁知道如何在 MATLAB 中抓取所有打开图形的句柄?

I have nine open figures in matlab (generated by another function) and I want to print them all to file. Does anyone know how to grab the handles of all open figures in MATLAB?

我知道 gcf 但它似乎没有做我想要的.

I know about gcf but it doesn't seem to do what I want.

推荐答案

有几种方法可以做到这一点.一种方法是获取 根对象的所有子项(在以前的版本中由句柄 0 表示):

There are a few ways to do this. One way to do this is to get all the children of the root object (represented in prior versions by the handle 0):

figHandles = get(groot, 'Children');  % Since version R2014b
figHandles = get(0, 'Children');      % Earlier versions

或者你可以使用函数 findobj:

Or you could use the function findobj:

figHandles = findobj('Type', 'figure');

如果任何图形具有隐藏句柄,您可以改为使用函数 findall:

If any of the figures have hidden handles, you can instead use the function findall:

figHandles = findall(groot, 'Type', 'figure');  % Since version R2014b
figHandles = findall(0, 'Type', 'figure');      % Earlier versions

这篇关于如何在 MATLAB 中获取所有打开图形的句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆