Azzera filtri
Azzera filtri

Create unkown number of checkboxes with UIControl

3 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Walter Roberson
Walter Roberson il 13 Ago 2015
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

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by