Main Content

Simulink.MDLInfo

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

The file name can include a partial path, complete path, relative 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('vdp')

Example: Simulink.MDLInfo('mymodel.slx')

Example: Simulink.MDLInfo('mydir/mymodel.slx')

Example: Simulink.MDLInfo('C:/mydir/mymodel.slx')

Data Types: char | string

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

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.

True or false result, returned as a 1 or 0 of data type logical.

  • 1 (true) — File is a library.

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

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.

Data Types: char

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.

Data Types: struct

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

Open the example. Then, open the vdp model.

open_system('vdp')

Create a Simulink.MDLInfo object that corresponds to the vdp.slx file.

info = Simulink.MDLInfo("vdp.slx");

Get information about the file, such as the type of file, by using dot notation to access the property values.

type = info.BlockDiagramType
type = 
'Model'

Open the sldemo_mdlref_depgraph model.

openProject("ModelReferenceHierarchy");

Get information about the sldemo_mdlref_depgraph model.

info = Simulink.MDLInfo('sldemo_mdlref_depgraph');

Get the interface information.

info.Interface
ans = struct with fields:
                       Inports: [0x1 struct]
                      Outports: [0x1 struct]
                     Trigports: [0x1 struct]
                   Enableports: [0x1 struct]
                   Actionports: [0x1 struct]
                    Resetports: [0x1 struct]
                     Connports: [0x1 struct]
                  ModelVersion: '10.0'
           SubsystemReferences: {0x1 cell}
               ModelReferences: {4x1 cell}
        ParameterArgumentNames: ''
            TestPointedSignals: [0x1 struct]
             ProvidedFunctions: [0x1 struct]
         IsExportFunctionModel: 0
         SimulinkSubDomainType: 'Simulink'
                   ResetEvents: [0x1 struct]
            DataStoreReference: [0x1 struct]
            HasInitializeEvent: 0
             HasTerminateEvent: 0
    PreCompExecutionDomainType: 'Unset'
             UseModelRefSolver: 0
                    SolverName: 'ode3'
            ParameterArguments: [0x1 struct]
         ExternalFileReference: [5x1 struct]

Get the referenced models.

info.Interface.ModelReferences
ans = 4x1 cell
    {'sldemo_mdlref_depgraph/heat2cost|sldemo_mdlref_heat2cost'      }
    {'sldemo_mdlref_depgraph/house|sldemo_mdlref_house'              }
    {'sldemo_mdlref_depgraph/outdoor temp|sldemo_mdlref_outdoor_temp'}
    {'sldemo_mdlref_depgraph/thermostat|sldemo_mdlref_heater'        }

Create a structure that contains metadata.

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

Create a new model.

new_system('MetadataModel')

Update the 'Metadata' parameter.

set_param('MetadataModel','Metadata',m)

Save the model with the metadata.

save_system('MetadataModel')

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

Simulink.MDLInfo.getMetadata('MetadataModel')
ans = struct with fields:
    ExpectedCompletionDate: 09/06/24
                TestStatus: 'untested'

Version History

Introduced in R2009b