Main Content

Programmatically Manage Simscape Block Parameter Data

You can access block parameter data and metadata for a Simscape block that you can programmatically author, edit, and store. When you access the parameter data and metadata, you interact with a partrepo.simscape.BlockDataSet object. The object comprises a block parameterization and an associated set of metadata. The parameterization contains a set of parameter data that corresponds to a Simscape block. You can choose whether to include only active parameters and whether to evaluate the parameters when you create the BlockDataSet object from a Simscape block. You can store block data as a JSON file with key-value pairs for version tracking.

Create Block Data Sets

To create a partrepo.simscape.BlockDataSet object:

  1. Parameterize a Simscape block according to your requirements.

  2. Use the partrepo.simscape.dataSetFromBlock function to create a block data set that contains the parameter data and metadata from that block.

In the BlockDataSet object, the Metadata and Parameters properties contain information about the metadata and parameter values, respectively.

The block data set contains the metadata and parameters to apply to the Simscape block.

Edit Block Data Sets

To edit block parameter data in the BlockDataSet object:

  1. Apply the parameters from the object to a Simscape block by using the applyParams function.

  2. Verify that the block behaves as expected with the new parameter settings.

  3. Use the partrepo.simscape.paramsFromBlock function to write the new block parameters to the BlockDataSet object.

To edit the block metadata, edit the properties of the partrepo.simscape.Metadata object. To remove a field, use the removeField function.

When you are finished editing the BlockDataSet object, use the validate function to validate the data set.

Import and Export Data from JSON Files

To import a BlockDataSet object from a JSON file, use the partrepo.importDataSetsFromJSON function. To export your data set, use the partrepo.exportDataSetsToJSON function.

See Also

Topics