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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by