Extract SLX or MDL file information without loading file
Simulink.MDLInfo
objects extract information from an SLX 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.
file
— Name of SLX or MDL fileName of the SLX 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
BlockDiagramName
— Name of block diagramThis property is read-only.
Name of the block diagram, returned as a character vector.
The name of the block diagram matches the SLX or MDL file name, but without an extension.
Data Types: char
BlockDiagramType
— Type of SLX or MDL fileThis property is read-only.
Type of SLX or MDL file, returned as a character vector.
Data Types: char
FileName
— Fully qualified SLX or MDL file nameThis property is read-only.
Fully qualified SLX or MDL file name, returned as a character vector.
Data Types: char
Interface
— Description of inputs, outputs, and referencesThis 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
IsLibrary
— True or false result1
| 0
This property is read-only.
True or false result, returned as a 1
or 0
of data type logical
.
1
(true
) — SLX or MDL file is a
library.
0
(false
) — SLX or MDL file is not a
library.
Data Types: logical
Description
— User-specified descriptionThis property is read-only.
User-specified description for the SLX or MDL file, returned as a character vector.
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
Metadata
— Names and values of arbitrary dataThis property is read-only.
Names and values of arbitrary data associated with the SLX or MDL file, returned as a structure.
The structure fields can be character vectors, numeric matrices of type
double
, or more structures.
To extract the metadata structure without loading the model or creating an
MDLInfo
object, use the Simulink.MDLInfo.getMetadata
function.
Data Types: struct
ReleaseUpdateLevel
— Release update used to save fileThis property is read-only.
Release update used to save the SLX or MDL 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
LastModifiedBy
— Name of user who last saved fileThis property is read-only.
Name of the user who last saved the SLX or MDL file, returned as a character vector.
Data Types: char
LastSavedArchitecture
— Platform used to save fileThis property is read-only.
Platform used to save the SLX or MDL file, returned as a character vector.
Example: 'glnxa64'
Data Types: char
ModelVersion
— Version numberThis property is read-only.
Version number of the SLX or MDL file, returned as a character vector.
Data Types: char
ReleaseName
— MATLAB release used to save fileThis property is read-only.
MATLAB release used to save the SLX or MDL file, returned as a character vector.
Example: 'R2020a'
Data Types: char
SavedCharacterEncoding
— Character encodingThis property is read-only.
Character encoding when the SLX or MDL file was saved, returned as a character vector.
Example: 'UTF-8'
Data Types: char
SimulinkVersion
— Simulink® version number used to save fileThis property is read-only.
Simulink version number used to save the SLX or MDL file, returned as a character vector.
Example: '10.1'
Data Types: char
Create a Simulink.MDLInfo
object that corresponds to the
vdp.slx
file.
info = Simulink.MDLInfo('vdp.slx');
Get information about the SLX file, such as the type of file, by using dot notation to access the property values.
type = info.BlockDiagramType
type = 'Model'
vdp
is a model file.
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: [0×1 struct] Outports: [0×1 struct] Trigports: [0×1 struct] Enableports: [0×1 struct] ModelVersion: '1.84' SubsystemReferences: {0×1 cell} ModelReferences: {4×1 cell} ParameterArgumentNames: '' TestPointedSignals: [0×1 struct] ProvidedFunctions: [0×1 struct] IsExportFunctionModel: 0 IsArchitectureModel: 0 IsAUTOSARArchitectureModel: 0 ResetEvents: [0×1 struct] HasInitializeEvent: 0 HasTerminateEvent: 0 PreCompExecutionDomainType: 'Unset' ParameterArguments: [0×1 struct] ExternalFileReference: [4×1 struct]
Get the referenced models.
info.Interface.ModelReferences
ans = 4×1 cell array {'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 information.
m.TestStatus = 'untested'; m.ExpectedCompletionDate = '01/01/2011';
Create a model, update the 'Metadata'
parameter, and save the
metadata in the model.
new_system('MDLInfoMetadataModel') set_param('MDLInfoMetadataModel','Metadata',m) save_system('MDLInfoMetadataModel')
Check the model for metadata by using an MDLInfo
object.
info = Simulink.MDLInfo('MDLInfoMetadataModel');
info.Metadata
ans = struct with fields: TestStatus: 'untested' ExpectedCompletionDate: '01/01/2011'