如何获取 MATLAB 中所有打开图形的句柄

发布于 2024-10-09 04:20:28 字数 107 浏览 0 评论 0原文

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

我了解 gcf,但它似乎没有达到我想要的效果。

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?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你怎么这么可爱啊 2024-10-16 04:20:28

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

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

或者您可以使用函数 findobj

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

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

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

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

Or you could use the function findobj:

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

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
贱人配狗天长地久 2024-10-16 04:20:28

最好的事情之一就是不需要寻找手柄。创建每个图形时,捕获其句柄。

h(1) = figure;
h(2) = figure;
...

正如这里的一位开发人员告诉我的:

它们被称为手柄,因为你应该抓住它们

One of the best things to do is to NOT need to look for the handles. When you create each figure, capture its handle.

h(1) = figure;
h(2) = figure;
...

As one of the developers here told me:

They are called handles, because you are supposed to hold on to them

阳光下慵懒的猫 2024-10-16 04:20:28

我认为 findall 应该可以

handles=findall(0,'type','figure ')

I think findall should work

handles=findall(0,'type','figure')

恰似旧人归 2024-10-16 04:20:28

对于手柄质量,您已经得到了很好的答案。但原始问题的另一个提示 - 打印所有要归档的数字:您可以使用 发布选项,不处理图形或句柄。

You've get fine answers for the handles mass. But another tip for the original question- print all the figures to file: you can use publish option, without dealing with figrues or handles.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文