views:

36

answers:

1

How do I obtain all the axes handles in a figure handle?

Given the figure handle hf, I found that get(hf, 'children') may return the handles of all axes. However, the Matlab Help suggests that it may return more than just the axes handles:

Children of the figure. A vector containing the handles of all axes, user-interface objects displayed within the figure. You can change the order of the handles and thereby change the stacking of the objects on the display.

Is there any way to obtain only the axes handle in the figure handle? Or how do I know if the handle returned by get(hf, 'children') is an axe handle?

Thanks!

+4  A: 

Use FINDALL:

allAxesInFigure = findall(figureHandle,'type','axes');

If you want to get all axes handles anywhere in Matlab, you could do the following:

allAxes = findall(0,'type','axes');

EDIT

To answer the second part of your question: You can test for whether a list of handles are axes by getting the handles type property:

isAxes = strcmp('axes',get(listOfHandles,'type'));

isAxes will be true for every handle that is of type axes.

Jonas

related questions