How to get the object handle?
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
'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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!