Contenuto principale

mw.fileTypes.open Extension Point

Specify default open action for file type

Since R2026a

You can specify the default action for opening different file types in MATLAB® using the mw.fileTypes.open extension point.

To specify the default open action for a file type in MATLAB:

  1. Create a JSON-formatted file named extensions.json and place it in a folder named resources.

  2. Add the mw.schemaVersion property as the first property in the extensions.json file and set the value to the schema version for your MATLAB release. For more information about schema versions, see Add Schema Version.

  3. Add a set of JSON declarations to extensions.json that defines the default open action for the file type.

  4. Add the folder containing the resources folder with the extensions.json file to the MATLAB path. To add the folder to the path, use the addpath function or right-click the folder in the Files panel and select Add to Path > Selected Folders and Subfolders.

This JSON code shows the basic structure of the mw.fileTypes.open extension point.

{
    "mw.schemaVersion": "1.0.0",
    "mw.fileTypes.open": {
        "xlsx": {
            "callback": "openxlsx"
        },
        "docx": {
            "callback": "opendocx"
        }
    }
}

For more information about using extension points, see Extend MATLAB Using Extension Points.

Properties

expand all

Open action for the specific file type, specified as an openAction object.

Specify the property name as the lowercase file type extension or file type group that you want to add an open action for. Specify the property value as an openAction object. For more information about the openAction object, see openAction Object Properties.

For example, to run the openxlsx function when you open files with a .xlsx extension, use this JSON declaration:

"xlsx": {
    "callback": "openxlsx"
}

For more information about file type groups, see mw.fileTypes.groups.

openAction Object Properties

Custom MATLAB function to run when you open a file, specified as a JSON string. For more information on defining the MATLAB function, see Create Custom MATLAB Function.

More About

expand all

Version History

Introduced in R2026a