Package: Simulink
Superclasses:
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(
creates
an instance of the 'mymodel'
)MdlInfo
class info
and
populates the properties with the information from the model file 'mymodel'
.
can be:mymodel
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. |
|
Type of block diagram. For example, 'Model', Subsystem', 'Library'. |
|
The Description parameter of the model. For details, see Access Model Information Programmatically. |
|
Contains the update release number that was used to save the SLX model. It
is zero if the SLX model was saved in a general release, for example,
It is zero for MDL files and for SLX files saved in releases before R2020a. |
|
The fully-qualified Name of the 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. Structure. |
|
Whether the block diagram is a library. Logical. |
|
Name of the user who last saved the model. |
|
Platform architecture when saved, for example,
|
|
Names and values 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
|
|
Model file version number. |
|
Release name that was used to save the model file, for example,
|
|
Character encoding when saved, for example,
|
|
Version number of Simulink® software that was used to save the model file. |
getDescription | Extract model file description without loading block diagram into memory |
getMetadata | Extract model file metadata without loading block diagram into memory |
Handle. To learn how this affects your use of the class, see Copying Objects (MATLAB) 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'; metadata.ExpectedCompletionDate = '01/01/2011'; load_system(mymodelname); set_param(mymodelname,'Metadata',... metadata) % must be a struct save_system(mymodelname); close_system(mymodelname);
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 info.Interface
Output:
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:
info.Interface.ModelReferences
Output is in the form model name
/ block path | referenced model name
:
ans = 'mpowertrain/Model Variants|manual_transmission' 'mpowertrain/engine model|menginemodel'