MATLAB Function Reference    
uigetfile

Interactively retrieve a filename

Syntax

Description

uigetfile displays a dialog box used to retrieve a file. The dialog box lists the files and directories in the current directory.

uigetfile('FilterSpec') displays a dialog box that lists files in the current directory. FilterSpec determines the initial display of files and can be a full filename or include the * wildcard. For example, '*.m' (the default) causes the dialog box list to show only MATLAB M-files.

uigetfile('FilterSpec','DialogTitle') displays a dialog box that has the title DialogTitle.

uigetfile('FilterSpec','DialogTitle',x,y) positions the dialog box at position [x,y], where x and y are the distance in pixel units from the left and top edges of the screen. Note that some platforms may not support dialog box placement.

[fname,pname] = uigetfile(...) returns the name and path of the file selected in the dialog box. After you press the Done button, fname contains the name of the file selected and pname contains the name of the path selected. If you press the Cancel button or if an error occurs, fname and pname are set to 0.

Remarks

If you select a file that does not exist, an error dialog appears. You can then enter another filename, or press the Cancel button.

Examples

This statement displays a dialog box that enables you to retrieve a file. The statement lists all MATLAB M-files within a selected directory. The name and path of the selected file are returned in fname and pname.

The exact appearance of the dialog box depends on your windowing system.

See Also
uiputfile


 Uicontrol Properties uiimport