Simulink.MDLInfo.getMetadata

Class: Simulink.MDLInfo
Package: Simulink

Extract model file metadata without loading block diagram into memory

Syntax

metadata = Simulink.MDLInfo.getMetadata('mymodel')
metadata = info.getMetadata

Description

metadata = Simulink.MDLInfo.getMetadata('mymodel') extracts the structure metadata associated with the file mymodel, without loading the model.

mymodel can be:

  • A block diagram name (for example, vdp)

  • The file name for a file on the MATLAB® path (for example, mymodel.slx)

  • A file name relative to the current folder (for example, mydir/mymodel.slx)

  • A fully qualified file name (for example, C:\mydir\mymodel.slx)

metadata = info.getMetadata returns the metadata property of the Simulink.MDLInfo object info.

metadata is a structure containing the names and attributes of arbitrary data associated with the model. The structure fields can be strings, numeric matrices of type "double", or more structures.

To add metadata to a model, create a metadata structure containing the information you require and use set_param to attach it to the model. If it is important to extract the information without loading the model, use metadata instead of adding custom user data with add_param.

Examples

Create a metadata structure and use set_param to attach it to the model:

  metadata.TestStatus = 'untested';
  metadata.ExpectedCompletionDate = '01/01/2011';
  load_system('mymodel');
  set_param('mymodel','Metadata',metadata) % must be a struct
  save_system('mymodel');
  close_system('mymodel');

Get the metadata without loading the model or creating a Simulink.MDLInfo object:

metadata = Simulink.MDLInfo.getMetadata('mymodel')

Create a Simulink.MDLInfo object containing all the model information properties, and get the metadata property:

info = Simulink.MDLInfo('mymodel')
metadata = info.getMetadata
Was this topic helpful?