필터 지우기
필터 지우기

How to get the object handle?

조회 수: 30 (최근 30일)
QiQin Zhan
QiQin Zhan 2013년 2월 22일
'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?

채택된 답변

Walter Roberson
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
QiQin Zhan
QiQin Zhan 2013년 2월 22일
Well,I've test it.Your code work well in the Callback Function.But when I put it in the subfunction of the Callback Function,it seems that it still returns an empty matrix? I'm confused.
Walter Roberson
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 CenterFile Exchange에서 Graphics Object Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by