Main Content


Open folder selection dialog box


selpath = uigetdir opens a modal dialog box that displays the folders in the current working directory and returns the path that the user selects from the dialog box.

This dialog box enables a user to navigate to a folder and select it (or type the name of a folder). If the specified folder exists, then MATLAB® returns the selected path as a character vector when the user clicks OK. If the user clicks Cancel or the close button (X) on the title bar, then MATLAB returns 0.


selpath = uigetdir(path) specifies the start path in which the dialog box opens. If path is empty or is not a valid path, then the dialog box opens in the current working directory.


selpath = uigetdir(path,title) specifies a title for the dialog box.


The visual characteristics of the dialog box depend on the operating system that runs your code. For instance, some operating systems do not show title bars on dialog boxes. If you pass a dialog box title to the uigetdir function, those operating systems do not display the title.


collapse all

dname = uigetdir('C:\');

Folder selection dialog box. The dialog lists the available folders on the drive, and has a Select Folder button and a Cancel button in the bottom right.

Pass the command form of the matlabroot function to uigetdir to display folders in the MATLAB root folder.

uigetdir(matlabroot,'MATLAB Root Folder');

Folder selection dialog box. The dialog title is MATLAB Root Folder.

Input Arguments

collapse all

The initial folder in which the dialog box opens, specified as character vector or string scalar.

Example: 'C:\Users\hharvey\Documents'

The dialog box title, specified as a character vector or string scalar

Example: 'Open Directory'

More About

collapse all

Modal Dialog Box

A modal dialog box prevents a user from interacting with other MATLAB windows before responding to the dialog box.

Version History

Introduced before R2006a