How to get the object handle?
26 ビュー (過去 30 日間)
古いコメントを表示
'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 件のコメント
採用された回答
Walter Roberson
2013 年 2 月 22 日
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 件のコメント
Walter Roberson
2013 年 2 月 22 日
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Specifying Target for Graphics Output についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!