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!
댓글 수: 0
채택된 답변
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 Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!