Checkbox in MATLAB App Building
MATLAB app builder allows you to create GUI apps without having proper software development knowledge. Matlab helps you create professional apps by just drag and dropping visuals according to your applications and writing code for its behavior. Later on, you can share your app either by sharing MATLAB drive or by creating standalone desktop and web apps with MATLAB Compiler. There are so many components available in Matlab App Builder.
In a user interface application, sometimes it is required to provide a list of options from which the user has to select any number of choices. This type of user interface(UI) component is called the Checkbox. It is basically a small square box where the user has to select and unselect to provide their preferences. These UI controls allow users to make selections. Creating Checkbox in MATLAB app designer, the steps are:
Step 1: Open MATLAB and select the APPS menu and click Design App under File group.
Step 2: Click the New option and select Blank app to create a new app. You can see so many components in the Component library placed on the left side and Component properties on the right-hand side.
Step 3: Drag and drop Check Box from the Component Library on the figure provided on the canvas.
Step 4: A check box gets displayed on the figure. You can see different properties of the Check Box at the side bar.
The properties of Check Box are:
- CHECK BOX: It helps you to change the text , value (whether selected or unselected) of the check box.
- FONT: It helps you to change the font name, size, color, and angle of the check box text.
- INTERACTIVITY: It allows you to make the checkbox visible, enable or provide tooltip text that will display some text when you hover over to the checkbox.
- POSITION: It allows you to change the position of the checkbox on the figure.
- CALLBACK EXECUTION CONTROL: It controls incorruptibility and action.
- PARENT/ CHILD: It handles visibility.
- IDENTIFIER: They are used to add tags to check box.
Step 5: We have dragged 5 checkboxes and changed their labels as C, JAVA, Python, C++, and MATLAB.
After dragging and dropping the check box on the figure, we will write code to add functionality to it. So now, right-click on the first check box, i.e., C and select the Callbacks function, and click on Go to CCheckBoxValueChanged callback option.
Step 6: It will take you to the code window, where it adds a function named CCheckBoxValueChanged ().
Here, is the app. checkbox. The value attribute is used to give the status of the checkbox whether it is selected or not. The state of the checkbox is 0 for unselect and 1 for select. We can write the code in the space provided :
we will write code for each checkbox following the steps given above.
Step 7: Click the Run button to run the code.
Please Login to comment...