MATLAB Functions Help Desk

uigetfile

Purpose

Interactively retrieve a filename

Syntax

Description

uigetfile displays a dialog box used to retrieve a file. The dialog lists the subdirectories in your current directory. The default position of the dialog box is the upper-left corner of your monitor.

uigetfile('filterSpec') displays a dialog box that lists the files in the current directory specified by 'filterSpec' . 'filterSpec' is a full filename or includes wildcards. A wildcard specification such as '*.m' does not provide a default file and the scroll box lists only files with the .m extension.

uigetfile('filterSpec','dialogTitle') displays a dialog box that has the title 'dialogTitle'.

uigetfile('filterSpec','dialogTitle',x) positions the upper-left corner of the dialog box at (x,0), where x is in pixel units. (Some platforms may not support dialog box placement.)

uigetfile('filterSpec','dialogTitle',x,y) positions the upper-left corner of the dialog box. x and y are the x- and y-position, in pixels, of the dialog box. (Some platforms may not support dialog box placement.)

[fname,pname] = uigetfile(...) returns the filename and pathname (or folder) 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 informs you that the file does not exist. You can then enter another filename, or press the Cancel button.

Examples

Retrieve a filename using uigetfile to list all MATLAB M-files within a selected directory (note that the figure shows the dialog box on a Macintosh):

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

See Also

uiputfile



[ Previous | Help Desk | Next ]