How do I use the status of a checkbox in the GUI for an input of a switch function?

8 次查看(过去 30 天)
I'm looking to have a few checkboxex that change the possible values of a dropdown menu.
For instance:
If checkbox A is selected, then the dropdown options would be X,Y,Z
If Checkbox B is selected, then the dropdown options would be A,B,C
I'm looking to have a switch function power this process and would think that I could assign a value to the selection of each checkbox and have that execute the switch.
I don't know how to get the checkbox data (numerical value) to the dropdown function.
Any help would be great.

回答(2 个)

Image Analyst
Image Analyst 2017-1-28
Try this:
% If checkbox A is selected, then the dropdown options would be X,Y,Z
if handles.checkboxA.Value
handles.dropdown.String = {'X', 'Y', 'Z'};
end
% If Checkbox B is selected, then the dropdown options would be A,B,C
if handles.checkboxB.Value
handles.dropdown.String = {'A', 'B', 'C'};
end

Walter Roberson
Walter Roberson 2017-1-27
get(handles.checkbox1,'value')
It will be 0 if not checked and 1 if checked (unless the max and min have been configured differently)

类别

Help CenterFile Exchange 中查找有关 Simulink Environment Customization 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by