How to return value from an axes ?

4 visualizaciones (últimos 30 días)
yogesh jain
yogesh jain el 29 de Feb. de 2016
Respondida: Deependra Mishra el 13 de Dic. de 2018
Hello all, How to return value of an axes in GUI, which is typically a numeric value. That value can be used to handle the axes outside the axes function also. thank you

Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Feb. de 2016
As of R2014b, graphics handles are no longer numeric values. There is not a lot of reason to need a numeric value for a graphics handle: you can just store and pass around the object-oriented handle instead.
If you really really need to get to the numeric value for some reason, then you can double() the object-oriented handle, but be warned that if you do so the recipients cannot make use of that to refer to the axes, not without using handle() on it. The only reason I have ever had for needing to know the numeric value of a graphics handle (other than a figure handle) is for debugging.
If you want to know the handle of the "current" axes, then call gca()
If you built the axes using GUIDE, and gave it a Tag, then you can pull its handle out of the "handles" structure by using the Tag as a field name.
If you create the axes at run-time, then record its handle and pass that around as needed
ax1 = axes('Units', 'norm', 'Position', [0 0 .3 .3]);
....
do_something_with_an_axes(ax1)
If you want to know the axes that a particular drawing object such as a lineseries object, then you can use ancestor(HandleOfGraphicsObject, 'axes')
If you created the axes with a Tag and the Tag is unique, you can findobj() or findall() against the Tag to find the axes. (If the tag is not unique, you would get all of the objects with the tag.) This is slower than the alternatives listed above, but can be very convenient.
  2 comentarios
yogesh jain
yogesh jain el 29 de Feb. de 2016
Hello Mr. Roberson , Thank you. I want to ask that how can I change this approach for using in GUIs . question It uses subplot function for showing children axes but I am using different axes in GUI . What should be the changes ?
Thanks again :)
Walter Roberson
Walter Roberson el 29 de Feb. de 2016
Nothing I have written is any different for GUI, other than the fact that when I am writing a GUI I would be even less likely to look at the numeric value of a handle and more likely to store the handles and refer to the stored handles.

Iniciar sesión para comentar.

Más respuestas (1)

Deependra Mishra
Deependra Mishra el 13 de Dic. de 2018
Here is a link I found, anyone one who come across this might want to have a look at...

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by