uigetfile
Open file selection dialog box
Syntax
Description
opens a modal
dialog box that lists files in the current folder. It enables a user to select or
enter the name of a file. If the file exists and is valid,
file
= uigetfileuigetfile
returns the file name when the user clicks
Open. If the user clicks Cancel or
the window close button (X), uigetfile
returns
0
.
___ = uigetfile(
specifies a file extension by which files displayed in the dialog box are filtered.
Use this syntax with any of the output argument combinations in the previous
syntaxes.filter
)
Typically, only files with a matching file extension are displayed. On some
platforms, uigetfile
displays files that do not match the
filter, but dims those file names. If the filter is missing or empty,
uigetfile
uses the default list of file types (for example,
all MATLAB® files).
___ = uigetfile(___,'MultiSelect',
specifies whether a user can select multiple files. Set the mode to
mode
)'on'
to enable multifile selection. By default it is set to
'off'
.
Windows® libraries can span multiple folders.
Note
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 uigetfile function, those operating systems do not display the title.
Examples
Input Arguments
Output Arguments
More About
Tips
Use the path and file name that
uigetfile
returns to open, read, or analyze the file using various input and output functions in MATLAB and MATLAB toolboxes. For example:imread
for reading images.xlsread
for reading Microsoft Excel files.open
,edit
, orrun
with MATLAB code files. For example, this code creates a dialog box to get a MATLAB code file name from the user, builds a full file name from the returned values, and then runs the user-specified code file.[file,location] = uigetfile('*.m'); selectedfile = fullfile(location,file); run(selectedfile);
Alternative Functionality
Use the dir
function to return a filtered or
unfiltered list of files in your current folder or a folder you specify. The
dir
function can return file attributes too.
Version History
Introduced before R2006a