how can I save the selected from radio button in text file?
조회 수: 1 (최근 30일)
이전 댓글 표시
There are 60 questions in a survey. There are 9 options for each question with radio buttons. When one of these 9 options is selected with radio buttons, how do I print or write the selected one in the text file? which code should I use? For each question you have these same 9 options. How can I show it in the text file?
댓글 수: 0
답변 (1개)
TADA
2019년 2월 7일
It realy depends on the design of your GUI
do you have a submit button or do you capture the selection of the radio button?
If you are using a uibuttongroup to achieve the radio behavior, you can use it to get the selected radio button, then you can get its text or whatever
lets say you have this figure:
figure();
h.grp = uibuttongroup(gcf, 'Units', 'norm', 'Position', [0.25, 0.25, 0.5, 0.5]);
h.r1 = uicontrol(h.grp, 'Units', 'norm', 'Position', [0, 0.7, 1, 0.3], 'Style', 'radiobutton', 'String', 'text 1');
h.r2 = uicontrol(h.grp, 'Units', 'norm', 'Position', [0, 0.35, 1, 0.3], 'Style', 'radiobutton', 'String', 'text 2');
set(h.r1, 'Value', 0);
set(h.r2, 'Value', 0);
now you can capture the selection chnaged event of the button group and do something with the selected radio button like that:
set(h.grp, 'SelectionChangedFcn', @(src, arg) disp(src.SelectedObject.String));
obviously this functionality to display the text of the selected radio button to the command window is useless, but you can subscribe just about any function to the changed event and save that value in a variable, analyze it, save it to a file or what ever you like...
댓글 수: 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!