How to get the object handle?
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
'axes_of_data' is the child object of 'figure' and figure is the current figure.
Then can I use the following code to get the handle of 'axes_of_data'?
Note:There are two axes in the figure.'axes_of_data'is one of them.
h = findobj(gcf,'Children','axes_of_data');
But why it returns an empty matrix?
0 Commenti
Risposta accettata
Walter Roberson
il 22 Feb 2013
The value of 'Children' properties are always object handles (usually in handle graphic numeric form), and are never strings.
Is 'axes_of_data' a variable name, or is it a field in your handles structure, or is it the Tag of the axes? (The last two could potentially be both true, especially if you are using GUIDE.)
If it is a Tag, then use
h = findobj(gcf, 'Tag', 'axes_of_data')
2 Commenti
Walter Roberson
il 22 Feb 2013
Is the gcf in fact returning the figure you expect?
Is the callback associated with a control on the same figure as you want to find the axes in? If so then if hObject is the name you gave to the first parameter to the callback, then
thisfig = ancestor(hObject, 'figure');
and then you would use
h = findobj(thisfig, 'Tag', 'axes_of_data');
You also need to consider the possibility that the axes has a hidden handle. By default, hidden handles are visible to findobj() within a callback associated with that handle, but are not visible to other callbacks. you can use findall() instead of findobj() if this might be interfering.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!