Hello, Let assume there is already a figure open (like a GUI). Before 2014b with gca the handle number returned. Now with gca a new figure will open.
How could I get the current handle of a figure back?
In my special case, I try to get access to a certain axes of an existing figure. Any help avialable?
Thanks!

3 comentarios

Geoff Hayes
Geoff Hayes el 12 de Oct. de 2014
Editada: Geoff Hayes el 12 de Oct. de 2014
Christian - in your scenario, what does the following return
fig = get(groot,'CurrentFigure');
if ~isempty(fig)
ax = fig.CurrentAxes;
end
Does fig correspond to your GUI (or is it empty), and is ax the handle to one or more axes in the figure (or is it empty)?
It works so fine in prior releases, but in 2014b the results as shown:
>> isempty(get(groot,'CurrentFigure'))
ans =
1
>>
Christian Schultes
Christian Schultes el 12 de Oct. de 2014
I've got the answer. The settings of the GUI must be HandleVisibility = ON !!!

Iniciar sesión para comentar.

 Respuesta aceptada

Christian Schultes
Christian Schultes el 12 de Oct. de 2014

0 votos

Always t
urn the HandleVisibility ON then the commands gca and gcf will work.

Más respuestas (1)

David Barry
David Barry el 12 de Oct. de 2014
Christian,
This seems to work fine. Are you sure you definitely have an axes in your figure? gca will only open a new figure with an axes in if you call it and one doesn't already exist.
Try the code below and see if returns 1
f = figure;
a = axes('Parent', f);
g = gca;
a == g

1 comentario

Christian Schultes
Christian Schultes el 12 de Oct. de 2014
Hello David.
Yes I'm sure. But now I found the issue! Not sure why it did work in R2011b. See my own answer.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Productos

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by