| MATLAB Function Reference | ![]() |
Display standard dialog box for selecting a directory
Syntax
directory_name = uigetdir directory_name = uigetdir('start_path') directory_name = uigetdir('start_path','dialog_title') directory_name = uigetdir('start_path','dialog_title',x,y)
Description
uigetdir displays a dialog box enabling the user to browse through the directory structure and select a directory.
directory_name = uigetdir
opens a dialog box in the current directory displaying the default title.
directory_name = uigetdir('start_path')
opens a dialog box in the directory specified by start_path.
directory_name = uigetdir('start_path','dialog_title')
opens a dialog box with the specified title.
directory_name = uigetdir(' positions the dialog box at position [start_path','dialog_title',x,y)
x,y], where x and y are the distance in pixel units from the left and top edges of the screen. This feature is only supported on UNIX platforms.
Returned directory_name
directory_name is a string containing the path to the directory selected in the dialog box. If the user presses the Cancel button or closes the dialog window, directory_name is returned as the number 0.
Specifying start_path
start_path specifies the directory to display when the dialog is first opened. If start_path is a string representing a valid directory path, the dialog box opens in the specified directory.
If start_path is an empty string (''), the dialog box opens in the current working directory.
If start_path is not a valid directory path, the dialog box opens in the base directory:
Specifying dialog_title
The placement of dialog_title in the dialog box depends on the computer system:
If you do not specify the dialog_title argument, MATLAB uses the default string Select Directory to Open.
Adding and Moving Directories
On Windows systems, users can click the New Folder button to add a new directory to the directory structure displayed. Users can also drag and drop existing directories.
Example 1
The following statement displays the directories on the C: drive.
The dialog box is shown in the following figure.
If the user selects the directory MATLAB6.5\help\techdoc, as shown in the figure, and clicks OK, uigetdir returns
Example 2
The following statement uses the matlabroot command to display the MATLAB root directory in the dialog box:
If the user selects the directory MATLAB6.5/notebook/pc, as shown in the figure, uigetdir returns a string like
assuming that MATLAB is installed on drive C:\.
See Also
| Uicontrol Properties | uigetfile | ![]() |
© 1994-2005 The MathWorks, Inc.