Create unkown number of checkboxes with UIControl

3 次查看(过去 30 天)
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 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