How to get the handles of all open shapes in MATLAB

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

I know about gcf , but it doesn't seem to be doing what I want.

+53
matlab matlab-figure
Dec 27 '10 at 17:43
source share
4 answers

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

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

Or you can use the findobj function:

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

If any shape has hidden handles , you can use the findall function findall :

 figHandles = findall(groot, 'Type', 'figure'); % Since version R2014b figHandles = findall(0, 'Type', 'figure'); % Earlier versions 
+70
Dec 27 '10 at 17:51
source share

One of the best things is NOT to look for pens. When you create each shape, write down its handle.

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

As one of the developers said:

They are called descriptors because you have to hold them

+13
Dec 27 '10 at 18:00
source share

I think findall should work

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

+9
Dec 27 '10 at 17:54
source share

You have great answers to a ton of descriptors. But one more tip for the original question: print all the numbers in the file: you can use publish without having to deal with shapes or pens.

+3
Nov 19 '13 at 23:31
source share