MATLAB Function Reference | ![]() ![]() |
Interactively retrieve a filename
Syntax
uigetfile uigetfile('FilterSpec
') uigetfile('FilterSpec
','DialogTitle
') uigetfile('FilterSpec
','DialogTitle
',x,y) [fname,pname] = uigetfile(...)
Description
uigetfile
displays a dialog box used to retrieve a file. The dialog box lists the files and directories in the current directory.
uigetfile('
displays a dialog box that lists files in the current directory. FilterSpec
')
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('
displays a dialog box that has the title FilterSpec
','DialogTitle
')
DialogTitle
.
uigetfile('
positions the dialog box at position [FilterSpec
','DialogTitle
',x,y)
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
.
[fname,pname] = uigetfile('*.m','Sample Dialog Box')
The exact appearance of the dialog box depends on your windowing system.
See Also
uiputfile
![]() | Uicontrol Properties | uiimport | ![]() |