Main Content

Simulink.MDLInfo.getMetadata

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

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'

Input Arguments

collapse all

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

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