| Contents | Index |
folder_name = uigetdir
folder_name = uigetdir(start_path)
folder_name = uigetdir(start_path,dialog_title)
folder_name = uigetdir displays a modal dialog box enabling the user 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 the user clicks OK. If the user types the name of a folder that does not exist, uigetdir returns the name of the current folder. If the user clicks Cancel or closes the dialog window, 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 like the one shown in 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 is like the one shown in 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.
The following statement displays directories on the C: drive.
dname = uigetdir('C:\');
The dialog box displays as follows (on Windows).

Selecting the directory Desktop, as shown in the figure, and clicking OK, uigetdir returns
dname = C:\WINNT\Profiles\All Users\Desktop
The following statement uses the matlabroot command to display the MATLAB root directory in the dialog box:
uigetdir(matlabroot,'MATLAB Root Directory')

Selecting the directory MATLAB6.5/notebook/pc, as shown in the figure, returns a string like
C:\MATLAB6.5\notebook\pc
assuming that MATLAB is installed on drive C:\.

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |