Main Content

Simulink.MDLInfo.getMetadata

R2026b

Extract SLX, SLXP, or MDL file metadata without loading file

Description

m = Simulink.MDLInfo.getMetadata(file) returns the metadata structure associated with the specified SLX, SLXP, or MDL file without loading the file.

The metadata structure contains the names and attributes of arbitrary data associated with the file. The structure fields can be character vectors, numeric matrices of type double, or more structures.

example

Examples

collapse all

Suppose you have a model on the MATLAB® path named myModel. Add metadata to the file, and then check the metadata.

Create a structure that contains metadata.

t=datetime('tomorrow','format','MM/dd/yy');
m.ExpectedCompletionDate = t;
m.TestStatus = 'untested';

Assign the metadata to the model.

set_param("myModel",Metadata=m);

Save the model with the metadata.

save_system("myModel");

Check the model for metadata without loading the model or creating a Simulink.MDLInfo object.

Simulink.MDLInfo.getMetadata("myModel")
ans = 
  struct with fields:

    ExpectedCompletionDate: 03/30/26
                TestStatus: 'untested'

Input Arguments

collapse all

Name or file path of the SLX, SLXP, or MDL file, specified as a string or character vector. You can specify a full file path or a relative file path. When you do not provide a file 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("myModel")

Example: Simulink.MDLInfo("myModel.slx")

Example: Simulink.MDLInfo("mydir/myModel.slx")

Example: Simulink.MDLInfo("C:/mydir/myModel.slx")

Data Types: string | character vector

Tips

To add metadata to an SLX or MDL file, create a metadata structure that contains the information you require and use the set_param function to attach it to the file. To extract the information without loading the file, use metadata instead of adding custom data by using the add_param function.

Version History

Introduced in R2009b