Open file selection dialog box and load selected file into workspace
uiopen opens a modal
dialog box entitled Open. The file filter in the dialog box is set to all
MATLAB® files. If the user enters a valid file name in the File
Name field and clicks Open, then MATLAB opens the specified file in the
appropriate application. If the appropriate application is not installed, then
either the file opens in the MATLAB Editor
or an error is returned.
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.
uiopen( sets the file filter
according to the type of file specified (which is not the same as the file
extension). For example, if type is
'figure', then MATLAB sets the filter to all figure files
uiopen( specifies the file name
that appears as the default value in the dialog box File name
field. Only files that have the same file extension are displayed in the dialog box.
If you specify a wildcard character and a file extension (such as
*.m), then no file name appears in the File
name field. The dialog box displays only files with the specified
type value appears in the filter field to the
right of the File name field.
Filter Files by Type
Display all the files in the current folder in the Open
dialog box. Then, rerun the
uiopen command to filter the
files by the
uiopen command with no arguments displays all
MATLAB files in the current
type argument to
display only those files that can be opened in the Editor. FIG-files,
MAT-files, SLX-files, MLAPP-files, and MLAPPINSTALL-files are excluded from
the list presented in the dialog box.
Filter Files by File Extension
Specify Default File
file input argument to a file
name. That file appears in the File name field when the
dialog box opens.
If the user clicks Open, then
surf.m opens in the MATLAB Editor.
If the user enters a different file in the File name
field and then clicks Open, then that file opens if
it is in the current folder. However, notice that only files with the same
file extension as the one specified in the
function call are listed in the Open dialog box.
type — file filter
'matlab' (default) |
File filter, specified as
'editor'. The files that MATLAB displays for each type value are as follows.
|All MATLAB files.
| All figure files
|All Simulink® model files (
|All MATLAB files except for
The only form of
uiopen that you can compile into a
standalone application is
uiopen('load'). To create a
file selection dialog box that you can compile, use
file — File name
character vector | string scalar
A file name, specified as a character vector or string scalar that
includes the file extension. If
tf is false (the
default), then the file name can be a wildcard character plus a file
extension. For example,
*.txt displays a list of all
files with the
.txt file extension.
tf — Logical open file
0 (default) | 1 | true | false
Logical open file specified as logical true (
logical false (
false, or a MATLAB expression that evaluates to logical true or false.
tf is set to
1, or evaluates to
1, then the
Open dialog box does not appear and MATLAB attempts to open the specified file in the
tf is set to
0 or evaluates to
0, then the Open
dialog box appears.
Modal Dialog Box
A modal dialog box prevents a user from interacting with other MATLAB windows before responding to the dialog box.
This table lists file extensions and the application in which such a file opens when a user selects a file with that extension and clicks Open. If the listed tool is not installed and the file is a text file, then the file opens in the MATLAB Editor. MATLAB returns an error if Simulink is not installed and the user selects a file with an
File Extension Where File Loads
MATLAB Figure window.
MATLAB App Designer.
MATLAB app installer
To open a file in Microsoft® Windows®, use the
You can also use these functions to open a file in a MATLAB code file or in a command.
Introduced before R2006a