Simulink.MDLInfo class

Package: Simulink

Extract model file information without loading block diagram into memory


The class Simulink.MDLInfo extracts information from a model file without loading the block diagram into memory.

You can create an MdlInfo object containing all the model information properties, or you can use the static methods for convenient access to individual properties without creating the class first. For example, to get the description only:

description = Simulink.MDLInfo.getDescription('mymodel')

To get the metadata only:

metadata = Simulink.MDLInfo.getMetadata('mymodel')

All model information properties are read only.


info = Simulink.MDLInfo('mymodel') creates an instance of the MdlInfo class info and populates the properties with the information from the model file 'mymodel'.

mymodel can be:

  • A block diagram name (for example, vdp)

  • The file name for a file on the MATLAB® path (for example, mymodel.slx)

  • A file name relative to the current folder (for example, mydir/mymodel.slx)

  • A fully qualified file name (for example, C:\mydir\mymodel.slx)

Simulink.MDLInfo resolves the supplied name by looking at files on the MATLAB path, and ignores any block diagrams in memory. This may cause unexpected results if you supply the name of a loaded model, but its file is shadowed by another file on the MATLAB path. If a file is shadowed, you see a warning in the command window. To avoid any confusion, supply a fully-qualified file name to Simulink.MDLInfo.



Name of block diagram.


Description of model.


Name of model file.


Names and attributes of the block diagram's root inports, outports, model references, etc., describing the graphical interface if you created a Model Reference block from this model.



Whether the block diagram is a library.


Platform architecture when saved, for example, 'glnxa64'.


Names and attributes of arbitrary data associated with the model.

Structure. The structure fields can be character vectors, numeric matrices of type "double", or more structures. Use the method getMetadata to extract this metadata structure without loading the model.


Model version number.


Name of release, for example, 'R2016a'.


Character encoding when saved, for example, 'UTF-8'.


Version number of Simulink® software that was used to save the model file.


getDescriptionExtract model file description without loading block diagram into memory
getMetadataExtract model file metadata without loading block diagram into memory

Copy Semantics

Handle. To learn how this affects your use of the class, see Copying Objects in the MATLAB Programming Fundamentals documentation.


Construct and view a model information object:

info = Simulink.MDLInfo('mymodel')
% Get the Version when the model was saved
simulink_version = info.SimulinkVersion; 
% Get model metadata
metadata = info.metadata

To add metadata to a model, create a metadata structure containing the information you require and use set_param to attach it to the model. For example:

  metadata.TestStatus = 'untested';
     = '01/01/2011';
  metadata)  % must be a struct

Construct a model information object for a model named mpowertrain, in order to find the names of referenced models without loading the model into memory:

info = Simulink.MDLInfo('mpowertrain')
% Get the Interface property


ans = 
                   Inports: [0x1 struct]
                  Outports: [0x1 struct]
                 Trigports: [0x1 struct]
                 Connports: [0x1 struct]
              ModelVersion: '1.122'
           ModelReferences: {2x1 cell}
    ParameterArgumentNames: ''
        TestPointedSignals: [0x1 struct]

Get the referenced models:


Output is in the form model name / block path | referenced model name:

ans = 
    'mpowertrain/Model Variants|manual_transmission'
    'mpowertrain/engine model|menginemodel'
Was this topic helpful?