MATLAB Function Reference
  Go to function:
    Search    Help Desk 
uigetfile    Examples   See Also

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. The Macintosh ignores this argument.

uigetfile('FilterSpec','DialogTitle') displays a dialog box that has the title DialogTitle. On the Macintosh, this argument specifies text that appears above the current folder name.

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

[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 figure shows the dialog box on a Macintosh. 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

[ Previous | Help Desk | Next ]