This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Open folder selection dialog box


selpath = uigetdir
selpath = uigetdir(path)
selpath = uigetdir(path,title)


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 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:\');

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

uigetdir(matlabroot,'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 modal dialog box.

Introduced before R2006a