MATLAB Function Reference    
uigetdir

Standard dialog box for selecting a directory

Syntax

Description

uigetdir displays a dialog box enabling the user to browser 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.

Remarks

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 if any error occurs, 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. Note that on Windows 2000 operating systems, the dialog box opens with the specified directory highlighted, but not open.

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 the 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.

Examples

This statement displays the directories on the Z drive (which in this example contains the MATLAB documentation CD).

If the user selects the techdoc directory, as show in the following picture,

dname contains the string

This statement uses the matlabroot command to displays the MATLAB root directory in the dialog box:

Suppose the user selects the demos/src directory, as shown in the following pictures:

On Windows computers, uigetdir returns a string like:

Assuming MATLAB is installed on drive J:\

On UNIX computers, uigetdir returns a string like:

Assuming MATLAB is installed in /devel/R12p1/perfect/.

See Also

uigetfile, uiputfile


  Uicontrol Properties uigetfile