How can i index various objects using a variable in their name?

2 ビュー (過去 30 日間)
Hugo
Hugo 2014 年 3 月 13 日
コメント済み: Hugo 2014 年 3 月 13 日
I don't know if the question makes sens as stated, but what i meant is this:
say i have 10 different edit boxes in my GUI, that I named edit_1 to edit-10 what i want is a way to call them without writing the same thing 10 times. I would like something like that for example:
for k=1:10 set(handles.edit_k,'visible', 'on'); end
is it possible?
thanks

採用された回答

W. Owen Brimijoin
W. Owen Brimijoin 2014 年 3 月 13 日
You can dynamically refer to different edit boxes by enclosing the field name in parentheses and supplying the numerical argument. This ought to get the behaviour you are looking for:
for k = 1:10, set(handles.(['edit_',num2str(k)]),'Visible','on'); end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by