Doug’s MATLAB Video Tutorials

February 20th, 2009

Using parent child relationships to find figures

This was a question that came across my desk recently: “How do I know what figure numbers are already open?” The way to answer this is to query the “root” (always handle 0) for its children. Figures are always children of the root and are the only direct children of the root. get(0, ‘children’) This video discusses the question in more depth and talks about the graphics family tree.

2 Responses to “Using parent child relationships to find figures”

  1. tomas replied on :

    Hi Doug,

    thank you for your postings and videos. i really like them. i have now a question regarding this posting here. how can i get the handle into a variable?

    i identify the figure i need using get(0,’children’) and then checking the name of the figure.

    now, if i know that my figure is the nr. 5 for example, how can i get the handle to it?

    handle = get(5);
    set(handle,’Name’,'test’)

    returns an error. handle is in this case not the handle, but the structure of the properties of the figure.

    thank you very much,

    tom

  2. Doug replied on :

    Tomas,

    In the above case, 5 is the handle. When you GET it, you are actually losing the handle that you want. Look at his example.

    a = figure(1)
    handle = a
    notHandle = get(a)

    -Doug

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

These postings are the author's and don't necessarily represent the opinions of The MathWorks.