Open file selection dialog box
___= 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 tomode
)'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.
Use the path and file name thatuigetfile
returns to open, read, or analyze the file using various input and output functions in MATLAB and MATLAB toolboxes. For example: listed here.
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.
(文件,路径)= uigetfile(“* m”);selectedfile =富尔语lfile(path,file); run(selectedfile);
Use thedir
function to return a filtered or unfiltered list of files in your current folder or a folder you specify. Thedir
function can return file attributes too.