フィルターのクリア

Create unkown number of checkboxes with UIControl

3 ビュー (過去 30 日間)
Jasmine Shragai
Jasmine Shragai 2015 年 8 月 13 日
コメント済み: Jasmine Shragai 2015 年 8 月 16 日
Hi Everyone!
In my code I'm required to create a number of checkboxes according to a number of lines in a file (which varies).
I know it's highly unrecommended to create variables and of course handles in a loop, so how can I apply this? Let's say I want to create: checkbox_1, checkbox_2, ...., checkbox_i And then extract the value of each checkbox in the end?
Great thanks in advance!

採用された回答

Walter Roberson
Walter Roberson 2015 年 8 月 13 日
button_strings = {'Rozencratz', 'Guildensteen', 'Top Gun', 'The Invisible Man'};
numbut = length(button_strings);
for K = 1 : numbut
button(K) = uicontrol('Style',...
'radiobutton', 'Value', 0,
'String', button_strings{K},...
'Position',[10 200+K*20 100 30]);
end
and later:
for K = 1 : numbut
buttonval(K) = get(button(K), 'Value');
end

その他の回答 (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