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
Input Arguments
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
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 theSimulink.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
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: [0×1 struct]
Outports: [0×1 struct]
Trigports: [0×1 struct]
Enableports: [0×1 struct]
Actionports: [0×1 struct]
Resetports: [0×1 struct]
Connports: [0×1 struct]
ModelVersion: '11.1'
SubsystemReferences: {0×1 cell}
ModelReferences: {4×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: 'ode3'
ParameterArguments: [0×1 struct]
ExternalFileReference: [5×1 struct]
Get the referenced models.
info.Interface.ModelReferences
ans = 4×1 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: 02/03/25
TestStatus: 'untested'
Version History
Introduced in R2009b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)