Specifications
List Box Directory Reader
5-19
Note The following links execute MATLAB commands and are designed to
work within the MATLAB Help browser. The first link adds a directory to your
MATLAB path.
Click here to display this GUI in the Layout Editor.
Click here to display the application M-file in the editor.
Implementing the GUI
The following sections describe the implementation.
•Specifying the Directory to List – shows how to pass a directory path as input
argument when the GUI is launched.
•Loading the List Box – describes the subfunction that loads the contents of
the directory into the list box. This subfunction also saves information about
the contents of a directory in the
handles structure.
•The List Box Callback – explains how the list box is programmed to respond
to user double clicks on items in the list box.
Specifying the Directory to List
You can specify the directory to list when the GUI is first opened by passing the
full pathname as a string input argument. If you do not specify a directory (i.e.,
if you call the application M-file with no input arguments), the GUI then uses
MATLAB’s current directory.
As generated, the application M-file launches the GUI when there are no input
arguments and calls a subfunction when the first input argument is a
character string. This example changes this behavior so that you can call the
M-file with:
•No input arguments – launch the GUI using MATLAB’s current directory.
•First input argument is a valid directory – launch the GUI, displaying the
specified directory.
•First input argument is not a directory, but is a character string and there is
more than one argument – execute the subfunction identified by the
argument (execute callback).