Documentation Center

  • Trial Software
  • Product Updates

uigetdir

Open standard dialog box for selecting directory

Syntax

folder_name = uigetdir
folder_name = uigetdir(start_path)
folder_name = uigetdir(start_path,dialog_title)

Description

folder_name = uigetdir displays a modal dialog box enabling you to navigate the folder hierarchy and select a folder or type the name of a folder. If the folder exists, uigetdir returns the selected path when you click OK. If you type the name of a folder that does not exist, uigetdir returns the name of the current folder. If you click Cancel, or close the dialog box, uigetdir returns 0. On Microsoft® Windows® platforms, uigetdir opens a dialog box in the base folder (the Windows desktop) with the current folder selected.

folder_name = uigetdir(start_path)opens a dialog box with the folder specified by start_path selected. If start_path is a valid path, the dialog box opens in the specified folder. If start_path is an empty string ('') or is not a valid path, the dialog box opens in the current folder.

folder_name = uigetdir(start_path,dialog_title) opens a dialog box with the specified title. On Windows and UNIX® platforms, the string replaces the default caption inside the dialog box for specifying instructions to the user. The default dialog_title is Select folder to Open.

On Windows platforms, you can click the New Folder button to add a new folder to the folder hierarchy displayed. You can also drag and drop existing directories into different folders.

On UNIX platforms, uigetdir opens a dialog box in the startup folder (the one you are in when you start MATLAB®), with the current directory selected. The dialog_title string replaces the default title of the dialog box. The dialog box looks similar to the following figure.

On Mac platforms, uigetdir opens a dialog box in the startup folder (the one you are in when you start MATLAB), with the current directory selected. The dialog box looks similar to the following figure.

    Note:   A modal dialog box prevents you from interacting with other MATLAB windows before responding. To block MATLAB program execution as well, use the uiwait function. For more information about modal dialog boxes, see WindowStyle in the MATLAB Figure Properties.

The pwd and cd functions return the name of the current folder.

Examples

The following statement displays directories on the C: drive.

dname = uigetdir('C:\');

A dialog box such as the following displays (on Windows).

If you double-click the Program Files folder, and the MATLAB subfolder, and then click Select Folder, uigetdir returns C:\Program Files\MATLABto dname:

 

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

uigetdir(matlabroot,'MATLAB Root Directory')

Assuming that MATLAB is installed on drive C:\, selecting the folder MATLAB\R2012b\notebook\pc from the dialog box, returns this string:

C:\Program Files\MATLAB\R2012b\notebook\pc

See Also

|

Was this topic helpful?