Main Content

Simulink.MDLInfo

R2026b

Extract SLX, SLXP, or MDL file information without loading file

Description

Simulink.MDLInfo objects extract information from an SLX, SLXP or MDL file without loading it into memory.

To extract the description and metadata from a file without creating an MDLInfo object, use the Simulink.MDLInfo.getDescription and Simulink.MDLInfo.getMetadata functions, respectively.

Creation

Description

info = Simulink.MDLInfo(file) creates an MDLInfo object called info and populates the properties with the information from the specified model file.

example

Input Arguments

expand all

Name of the SLX, SLXP, or MDL file, specified as a character vector or string.

The file name can include a relative path, absolute path, or no path. When you do not provide a path, the file extension is optional.

To avoid unexpected results caused by shadowed files that share a name, specify a fully qualified file name.

Example: Simulink.MDLInfo("myModel")

Example: Simulink.MDLInfo("myModel.slx")

Example: Simulink.MDLInfo("mydir/myModel.slx")

Example: Simulink.MDLInfo("C:/mydir/myModel.slx")

Data Types: string | char

Properties

expand all

File Name and Contents

This property is read-only.

Name of the block diagram, returned as a character vector.

The name of the block diagram matches the file name, but without an extension.

Data Types: char

This property is read-only.

Type of file, returned as a character vector.

Data Types: char

Since R2026a

This property is read-only.

Simulink subdomain, returned as a character vector.

  • 'Simulink' — File is a Simulink model

  • 'Architecture' — File contains a System Composer™ diagram

  • 'AUTOSARArchitecture' — File contains an AUTOSAR diagram

Data Types: char

This property is read-only.

Fully qualified file name, returned as a character vector.

Data Types: char

This property is read-only.

Description of inputs, outputs, and references, returned as a structure.

The structure includes the names and attributes of the top-level ports, model references, and subsystem references.

Data Types: struct

This property is read-only.

Whether the model is a library, returned as a logical.

  • 1 (true) — Model is a library.

  • 0 (false) — Model is not a library.

Data Types: logical

Since R2026a

This property is read-only.

Whether model contains subsystems, returned as a logical.

  • 1 (true) — File is contains a Subsystem block.

  • 0 (false) — File does not contain a Subsystem block.

Data Types: logical

Since R2026a

This property is read-only.

Whether model contains test harnesses, returned as a logical.

  • 1 (true) — Model file contains a Simulink test harness.

  • 0 (false) — Model file does not contains a Simulink test harness.

Data Types: logical

User-Specified Information

This property is read-only.

User-specified description for the file, returned as a character vector.

Tips

  • To extract the description without loading the model or creating an MDLInfo object, use the Simulink.MDLInfo.getDescription function.

  • To view the description without loading the model or creating an MDLInfo object, in the MATLAB® Command Window, enter:

    help 'mymodelname'

  • To view the description for an open model, open the Description tab in the Model Properties dialog box.

This property is read-only.

Names and values of arbitrary data associated with the file, returned as a structure.

The structure fields can be character vectors, numeric matrices of type double, or more structures.

Tips

To extract the metadata structure without loading the model or creating an MDLInfo object, use the Simulink.MDLInfo.getMetadata function.

Save Information

This property is read-only.

Release update used to save the file, returned as a positive integer.

  • 0 — The file was saved in a general release, for example, 'R2020a', or was saved in a release before R2020a.

  • Positive integer — The file was saved in an update release, for example, 2, if the model was saved in 'R2020a Update 2'.

Data Types: int32

This property is read-only.

Name of the user who last saved the file, returned as a character vector.

Data Types: char

This property is read-only.

Platform used to save the file, returned as a character vector.

Example: 'glnxa64'

Data Types: char

This property is read-only.

Version number of the file, returned as a character vector.

Data Types: char

This property is read-only.

MATLAB release used to save the file, returned as a character vector.

Example: 'R2020a'

Data Types: char

This property is read-only.

Character encoding when the file was saved, returned as a character vector.

Example: 'UTF-8'

Data Types: char

This property is read-only.

Simulink version number used to save the file, returned as a character vector.

Example: '10.1'

Data Types: char

Examples

collapse all

Suppose you have a file named myModel.slx. Get the file type.

Create a Simulink.MDLInfo object for the file.

infoObj = Simulink.MDLInfo("myModel.slx");

Get the file type.

fileType = infoObj.BlockDiagramType
fileType =
    'Model'

Suppose you have model named myModel. Get the file paths of all referenced models in myModel without loading myModel.

Create a Simulink.MDLInfo object for the model.

infoObj = Simulink.MDLInfo("myModel");

Get the interface information.

fileType = infoObj.Interface
fileType = 
  struct with fields:

                       Inports: [0×1 struct]
                      Outports: [1×1 struct]
                     Trigports: [0×1 struct]
                   Enableports: [0×1 struct]
                   Actionports: [0×1 struct]
                    Resetports: [0×1 struct]
                     Connports: [0×1 struct]
                  ModelVersion: '1.1'
           SubsystemReferences: {0×1 cell}
               ModelReferences: {0×1 cell}
        ParameterArgumentNames: ''
            TestPointedSignals: [0×1 struct]
             ProvidedFunctions: [0×1 struct]
         IsExportFunctionModel: 0
         SimulinkSubDomainType: 'Simulink'
                   ResetEvents: [0×1 struct]
            DataStoreReference: [0×1 struct]
            HasInitializeEvent: 0
             HasTerminateEvent: 0
    PreCompExecutionDomainType: 'Unset'
             UseModelRefSolver: 0
                    SolverName: 'VariableStepAuto'
            ParameterArguments: [0×1 struct]
         ExternalFileReference: [0×1 struct]

Get the file paths of the model references.

modelRefs = infoObj.Interface.ModelReferences;

Suppose you have a model on the MATLAB path named myModel. Add metadata to the file, and then check the metadata.

Create a structure that contains metadata.

t=datetime('tomorrow','format','MM/dd/yy');
m.ExpectedCompletionDate = t;
m.TestStatus = 'untested';

Assign the metadata to the model.

set_param("myModel",Metadata=m);

Save the model with the metadata.

save_system("myModel");

Check the model for metadata without loading the model or creating a Simulink.MDLInfo object.

Simulink.MDLInfo.getMetadata("myModel")
ans = 
  struct with fields:

    ExpectedCompletionDate: 03/30/26
                TestStatus: 'untested'

Version History

Introduced in R2009b

expand all