User`s guide
Access Workspace Variables from a List Box (GUIDE)
To just inspect the GUI in GUIDE and run it, follow these steps instead:
1 ClickheretoaddtheexamplefilestotheMATLABpath(onlyforthe
current session).
2 Clickheretorunthelb GUI.
3 ClickheretodisplaytheGUIintheGUIDELayoutEditor(readonly).
4 ClickheretodisplaytheGUIcodefileintheMATLABEditor(readonly).
Note Do not save GUI files to the examp les folder where you found them
or you will overwrite the original files. If you want to save G U I files, use
File > Save as from G UIDE, which saves both the GUI FIG-file and the
GUI code file.
Read Workspace Variables
When the GUI initializes, it needs to query the w orkspace variables and s et
the list box
String property to display these variable names. Adding the
following subfunction to the GUI code accomplishes this using
evalin to
execute the
who commandinthebaseworkspace.Thewho command returns a
cell array of strings, which are used to populate the list box.
function update _lis tbox(handles)
vars = evalin('base','who');
set(handles.listbox1,'String',vars)
The function’s input argument is the handles structure set up by the GUIDE.
This structure contains the handle of the list box, as well as the handles of all
other components in the GUI.
The callback for the Up date Listbox push button also calls
update_listbox.
10-63