Creating Graphical User Interfaces | ![]() ![]() |
Reading Workspace Variables
When the GUI initializes, it needs to query the workspace variables and set the list box String
property to display these variable names. The following subfunction added to the application M-file accomplishes this using evalin
to execute the who
command in the base workspace. The who
command returns a cell array of strings, which are used to populate the list box.
function update_listbox(handles) vars = evalin('base','who'); set(handles.listbox1,'String',vars)
The function's input argument is the handles structure generated by the application M-file. This structure contains the handle of the list box, as well as the handles all other components in the GUI.
The callback for the Update Listbox push button also calls update_listbox
.
![]() | Accessing Workspace Variables from a List Box | Reading the Selections from the List Box | ![]() |