Question about two Checkboxes being checked and increment a number
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Adam Danz
am 2 Okt. 2019
Bearbeitet: Adam Danz
am 2 Okt. 2019
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 Kommentar
Adam Danz
am 2 Okt. 2019
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?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!