Question about two Checkboxes being checked and increment a number
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
MHS
el 1 de Oct. de 2019
Comentada: Adam Danz
el 2 de Oct. de 2019
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 comentarios
Respuesta aceptada
Adam Danz
el 2 de Oct. de 2019
Editada: Adam Danz
el 2 de Oct. de 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 comentario
Adam Danz
el 2 de Oct. de 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?
Más respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!