h(i) = strcat('ha​ndles.uipa​nel',num2s​tr(i)), when I use set(h(i),'Visible','ON') ,it doesn't work

조회 수: 2 (최근 30일)
Well ,I have a for ...end
for b=1:9
h = strcat('handles.uipanel',num2str(b));
set(h,'Visible','ON');
end
Error:Error using set; Value must be a handle.
Thank you for your help!

채택된 답변

Walter Roberson
Walter Roberson 2013년 1월 24일
편집: Walter Roberson 2013년 1월 24일
In your situation you could use the dynamic fieldname approach.
  댓글 수: 2
Jan
Jan 2013년 1월 24일
I would even prefer not to let GUIDE create "handles.uipanel1", "handles.uipanel2", ..., but to create an array instead: "handles.uipanel(1)", etc. Then the loop can be omitted:
set(h.uipanel, 'Visible', 'ON');
But unfortunately the automatic code generation in GUIDE prefers to append the index to the name of the field. Then Walter's suggestion means:
for b = 1:9
set(handles.sprintf('uipanel%d', b), 'Visible', 'on');
end
Lisa Wu
Lisa Wu 2013년 1월 29일
Thank you very much! As you said ,I have used an array!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by