Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the handles of all open figures in 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?

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

like image 210
Liz Avatar asked Dec 27 '10 17:12

Liz


People also ask

How do you get a figure handle in MATLAB?

To get the handle of the current figure without forcing the creation of a figure if one does not exist, query the CurrentFigure property on the root object. fig = get(groot,'CurrentFigure'); MATLAB® returns fig as an empty array if there is no current figure.

What is the command for closing all opened figures in MATLAB?

close( fig ) closes the figure specified by fig . close all closes all figures whose handles are visible. A figure handle is hidden if the HandleVisibility property is set to 'callback' or 'off' . close all hidden closes all figures, including figures with hidden handles.

How do I open figure properties in MATLAB?

'on' — Figure can be docked in the MATLAB® desktop. The Desktop > Dock Figure menu item and the Dock Figure button in the menu bar are enabled.

What is GCA and GCF in MATLAB?

gca and gcf The axis has properties that describe the characteristics of your axes. To list all properties of the figure, you can type get(gcf) (which stands for get current figure). To list all properties of the axis, you can type get(gca) (which stands for get current axis).


1 Answers

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 
like image 100
gnovice Avatar answered Sep 21 '22 21:09

gnovice