Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

uigetdir - Open standard dialog box for selecting directory

Syntax

uigetdir
directory_name = uigetdir
directory_name = uigetdir(start_path)
directory_name = uigetdir(start_path,dialog_title)

Description

uigetdir displays a modal dialog box enabling the user to browse through the directory structure and select a directory or type the name of a directory. If the directory exists, uigetdir returns the selected path when the user clicks OK. For Microsoft Windows platforms, uigetdir opens a dialog box in the base directory (the Windows desktop) with the current directory selected. See Remarks for information about UNIX and Mac platforms.

directory_name = uigetdir returns the path to the selected directory when the user clicks OK. If the user clicks Cancel or closes the dialog window, directory_name is set to0.

directory_name = uigetdir(start_path) opens a dialog box with the directory specified by start_path selected. If start_path is 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 directory. If start_path is not a valid directory path, the dialog box opens in the base directory. For Windows, this is the Windows desktop. See Remarks for information about UNIX and Mac platforms.

directory_name = uigetdir(start_path,dialog_title) opens a dialog box with the specified title. On Windows platforms, the string replaces the default caption inside the dialog box for specifying instructions to the user. The default dialog_title isSelect Directory to Open. See Remarks for information about UNIX and Mac platforms.

Remarks

For Windows platforms, the dialog box is similar to those shown in the Examples below.

For UNIX platforms, uigetdir opens a dialog box in the base directory (the directory from which MATLAB is started) with the current directory selected. The dialog_title string replaces the default title of the dialog box. The dialog box is similar to the one shown in the following figure.

For Mac platforms,uigetdir opens a dialog box in the base directory (the current directory) with the current directory open. The dialog_title string, if any, is ignored. The dialog box is similar to the one shown in the following figure.

Examples

Example 1

The following statement displays directories on the C: drive.

dname = uigetdir('C:\');

The dialog box is shown in the following figure.

If the user selects the directory Desktop, as shown in the figure, and clicks OK, uigetdir returns

dname =
C:\WINNT\Profiles\All Users\Desktop

Example 2

The following statement uses the matlabroot command to display the MATLAB root directory in the dialog box:

uigetdir(matlabroot,'MATLAB Root Directory')

If the user selects the directory MATLAB6.5/notebook/pc, as shown in the figure, uigetdir returns a string like

C:\MATLAB6.5\notebook\pc

assuming that MATLAB is installed on drive C:\.

See Also

uigetfile, uiputfile

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS