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
file
— Name of SLX, SLXP, or MDL file
character vector | string scalar
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
BlockDiagramName
— Name of block diagram
character vector
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
BlockDiagramType
— Type of file
character vector
This property is read-only.
Type of file, returned as a character vector.
Data Types: char
FileName
— Fully qualified file name
character vector
This property is read-only.
Fully qualified file name, returned as a character vector.
Data Types: char
Interface
— Description of inputs, outputs, and references
structure
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
IsLibrary
— True or false result
1
| 0
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
Description
— User-specified description
character vector
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
Metadata
— Names and values of arbitrary data
structure
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
ReleaseUpdateLevel
— Release update used to save file
positive integer
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
LastModifiedBy
— Name of user who last saved file
character vector
This property is read-only.
Name of the user who last saved the file, returned as a character vector.
Data Types: char
LastSavedArchitecture
— Platform used to save file
character vector
This property is read-only.
Platform used to save the file, returned as a character vector.
Example: 'glnxa64'
Data Types: char
ModelVersion
— Version number
character vector
This property is read-only.
Version number of the file, returned as a character vector.
Data Types: char
ReleaseName
— MATLAB release used to save file
character vector
This property is read-only.
MATLAB release used to save the file, returned as a character vector.
Example: 'R2020a'
Data Types: char
SavedCharacterEncoding
— Character encoding
character vector
This property is read-only.
Character encoding when the file was saved, returned as a character vector.
Example: 'UTF-8'
Data Types: char
SimulinkVersion
— Simulink® version number used to save file
character vector
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
Get Model Information
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'
Find Referenced Models Without Loading Top 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' }
Add and Check File Metadata
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
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)