Main Content


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(type) 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 (*.fig).


uiopen(file) 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 extension. The type value appears in the filter field to the right of the File name field.

uiopen(file,tf) opens the specified file without displaying the Open dialog box when the value of tf is logical true (1). The Open dialog box is displayed when the value of tf is logical false (0).


collapse all

Display all the files in the current folder in the Open dialog box. Then, rerun the uiopen command to filter the files by the 'editor' type.


Open dialog box. The dialog box contains a panel with a list of folders, and a panel with a list of files in the currently selected folder. The bottom of the box has a field for the selected file name, a drop-down list with file filters, an Open button, and a Cancel button.

The uiopen command with no arguments displays all MATLAB files in the current folder.

Set the type argument to 'editor' 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.


Open dialog box. The list of files only contains .m files.


Open dialog box. The list of files only contains .m files. The file filter drop-down value is (*.m).

Set the file input argument to a file name. That file appears in the File name field when the dialog box opens.


Open dialog box. The file name edit field displays "surf.m".

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 uiopen function call are listed in the Open dialog box.

Input Arguments

collapse all

File filter, specified as 'matlab', 'load','figure','simulink', or 'editor'. The files that MATLAB displays for each type value are as follows.

Type ValueFiles Displayed
'matlab'All MATLAB files.
'load'All MAT-files (*.mat)
'figure' All figure files (*.fig)
'simulink'All Simulink® model files (*.mdl and *.slx)
'editor'All MATLAB files except for .mat, .fig, .slx , .mlapp, and .mlappinstall files

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 uigetfile.

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.

Example: 'surf.m'

Example: 't.fig'

Example: '*.mat'

Logical open file specified as logical true (1), logical false (0), true, false, or a MATLAB expression that evaluates to logical true or false.

If tf is set to true, 1, or evaluates to 1, then the Open dialog box does not appear and MATLAB attempts to open the specified file in the appropriate tool.

If tf is set to false, 0 or evaluates to 0, then the Open dialog box appears.

Example: 1

Example: true

More About

collapse all

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 .mdl or .slx file extension.

    File ExtensionWhere File Loads
    .m or .mlx MATLAB Editor
    .figMATLAB Figure window.
    .matMATLAB workspace.

    MATLAB App Designer.

    .mlappinstall MATLAB app installer
    .mdl or .slxSimulink
  • To open a file in Microsoft® Windows®, use the winopen function.


You can also use these functions to open a file in a MATLAB code file or in a command.

File to OpenFunction
Based on file extensionopen
In the Editoredit

Version History

Introduced before R2006a

See Also