MATLAB Answers

Multiple check boxes to check to provide an output

31 views (last 30 days)
I have 6 checkboxes with 6 different conditions to run a query. User will select any number of check boxes (may be only 1 or may be all 6 or may be only 3 checkboxes). For example, let's say if user selects checkbox 1 and checkbox 2, then by selecting a 'search' pushbutton, the result will show one output or if user selects all checkboxes then the search will shows a different output.

  1 Comment

Mehmed Saad
Mehmed Saad on 17 Aug 2020
what have you done so far?
Show us your code

Sign in to comment.

Accepted Answer

Prabhanjan Mentla
Prabhanjan Mentla on 20 Aug 2020
Edited: Prabhanjan Mentla on 20 Aug 2020
I assume that on selecting the combinations checkboxes the text should vary, on clicking a button.
For accessing the checkbox values, you may code something like below
function ButtonPushed(app, event)
fieldNames = fieldnames(app); % get the uicomponents
allCheckBoxNamesList = fieldNames(contains(fieldNames,'CheckBox','IgnoreCase',true)); % get the checkboxes
for i = 1:numel(allCheckBoxNamesList) % loop through all checkboxes
if app.(allCheckBoxNamesList{i}).Value == true % display all the checkboxes which are true
app.TextArea.Value = [string(app.TextArea.Value);app.(allCheckBoxNamesList{i}).Text;] % append to Text Area
You may get something like below
Hope this helps.


Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!