Question about two Checkboxes being checked and increment a number
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello friends. I am generating an output number based on a certain criteria. When I click on one checkbox, I display the value as 1, and when I click on the second checkbox, the value is 1 as well. However, when both checkboxes are clicked, the value should be 2. I am unable to output 2 in my pushbutton even after declaring a variable. If anyone can help, it will be great. Thank you so much :) Here is my code below:
ml = get(handles.checkbox_trial,'Value');
ml1 = get(handles.checkbox1,'Value');
ml2 = get(handles.checkbox2,'Value');
if ml == 1
handles.Level = '0'
elseif ml1 == 1
handles.Level = '1'
elseif ml2 == 1
handles.Level = '1'
elseif ...
msgbox([handles.Level]);
The last elseif condition can be edited. I was thinking of adding by using a level number like handles.Level = 0; and then incrementing the number, but it is not working
댓글 수: 0
채택된 답변
Adam Danz
2019년 10월 2일
편집: Adam Danz
2019년 10월 2일
ml = get(handles.checkbox_trial,'Value');
ml1 = get(handles.checkbox1,'Value');
ml2 = get(handles.checkbox2,'Value');
if ml == 1
handles.Level = '0'
else
handles.Level = num2str(ml1 + ml2);
end
msgbox([handles.Level]);
댓글 수: 1
Adam Danz
2019년 10월 2일
I'm lost at:
"Only for the first radiobutton my ouput should be 0(Not Observed), 0.5(Observed) and 1(Observed). For the rest of radiobuttons my output should be 0, 0.25 and 0.5."
Radiobuttons do not have outputs. Their value is binary (0/1). You can assign weights to those values such as handles.radioButton1.Value * 0.5.
Is that what you're doing?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!