How to Remove a List Box Entry in MATLAB
MATLAB is a technical software environment used for data collection, analysis, simulation and display. Often in the course of your workflow, it is necessary to allow a user to input decisions in the workflow, rather than perform a completely automated process. However, the options available for user interface elements, such as list boxes, can be manipulated via programming.
Instructions
-
-
1
Create a cell array of strings containing the options for the list box, in order, as follows:
my_options = {'First' 'Second' 'Third'};
-
2
Create and display a list dialog box using the listdlg() function as in the following example:
[selection, was_ok] = listdlg('PromptString','Make a selection:','ListString',my_options);
MATLAB pauses execution and does not allow input while the dialog box is open. The return values are the index of the selected value(s) and a boolean indicating whether the dialog was closed with the "OK" or "Cancel" button.
-
-
3
Access the current list of list box selections created using MATLAB's interactive graphical user interface creator, GUIDE, using the get() function. The list_box_handle is the handle to your list box graphics object:
current_list = get(list_box_handle,'String');
-
4
Set a new list of selections in your list box using the set() function:
set(list_box_handle,'String',my_options);
-
1
References
- Photo Credit Hemera Technologies/Photos.com/Getty Images