Question about two Checkboxes being checked and increment a number
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Adam Danz
le 2 Oct 2019
Modifié(e) : Adam Danz
le 2 Oct 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 commentaire
Adam Danz
le 2 Oct 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?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!