Main Content

Model Transformer Tasks

Use the Model Transformer app to refactor a model to implement variants, eliminate eligible data store blocks, and improve the simulation and code efficiency of table lookup operations. You can perform the steps in the Model Transformer all at once or one step at a time.

Transformations

You can use the Model Transformer app to replace:

  • Qualifying modeling patterns with variant blocks.

  • Data store blocks with blocks that make data dependency explicit

  • Lookup Table blocks with Interpolation using Prelookup blocks

  • Modeling patterns with multiple Interpolation using Prelookup blocks into a single Interpolation using Prelookup block

If you want to perform all the transformations, for each step, specify the input parameters. Then, click the Run Selected Checks button. After you run each check, create new models with the transformations by clicking the Refactor Model buttons.

If you want to perform one transformation at a time, you can individually select the checks.

Replace Modeling Patterns with Variant Blocks

Select the Transform model to variant system button to identify system constants to use in variant transformations and blocks that qualify for transformation into Variant Subsystem or Variant Source blocks. These transformations are possible:

  • If an If block connects to one or more If Action Subsystem blocks and each If Action Subsystem block has one output port, replace this modeling pattern with a subsystem and a Variant Source block.

  • If an If block connects to an If Action Subsystem block that has no output port or two or more output ports, replace this modeling pattern with a Variant Subsystem block.

  • If a Switch Case block connects to one or more Switch Case Action Subsystem blocks and each Switch Case Action Subsystem block has one output port, replace this modeling pattern with a subsystem block and a Variant Source block.

  • If a Switch Case block connects to a Switch Case Action Subsystem block that has no output port or two or more output ports, replace this modeling pattern with a Variant Subsystem block.

  • Replace a Switch block with a Variant Source block.

  • Replace a Multiport Switch block that has two or more data ports with a Variant Source block.

Note

For some modelling patterns and settings, the Model Transformer cannot perform each one of the preceding transformations.

A system constant is a control input or part of an arithmetic expression that forms the control input to Multiport Switch or Switch blocks and the inputs to If or Switch Case blocks. You must use Constant blocks and a combination of blocks that form a supported MATLAB expression as the control input of these blocks. In the Constant block, the Constant value parameter is the system constants. In the transformed model, system constants are part of condition expressions in Variant Source or Variant Subsystem blocks.

After you run this transformation, the Result table displays each modeling pattern with a hyperlink to the corresponding location in the model. If you do not want the Model Transformer to perform a transformation, clear the check box next to the pattern.

Click Refactor Model to create a model that contains the transformations. The app creates the transformed model in a folder with the name m2m_<original model name>.

For an example that converts blocks in a model to variant block, see Transform Model to Variant System.

Eliminate Data Store Blocks

Select Eliminate data store blocks to identify Data Store Memory, Data Store Read, and Data Store Write blocks that qualify for elimination. Click the Refactor Model button to create a model that replaces these blocks with either a direct signal line, Delay block, or Merge block.

Replacing these blocks improves model readability by making the data dependency explicit. The Model Transformer can replace these data stores:

  • For signals that are not buses, if a Data Store Read block executes before a Data Store Write block, the app replaces these blocks with a Delay block.

  • For signals that are not buses, if a Data Store Write block executes before a Data Store Read block, the app replaces these blocks with a direct connection.

  • For bus signals, if the write to bus elements executes before the read of the bus, the app replaces the Data Store Read and Data Store Write blocks with a direct connection and a Bus Creator block.

  • For bus signals, if the write to the bus executes before the read of bus elements, the app replaces the Data Store Read and Data Store Write blocks with a direct connection and a Bus Selector block.

  • For conditionally executed subsystems, the app replaces the Data Store Read and Data Store Write blocks with a direct connection and a Merge block.

The Model Transformer app only eliminates local data stores that Data Store Memory blocks define. The app does not eliminate global data stores. For the Data Store Memory block, on the Signal Attributes tab of the Block Parameters dialog box, the Data store name must resolve to Simulink signal object parameter must be cleared.

After you run this transformation, the Result table displays hyperlinks to the corresponding Data Store Memory, Data Store Read, and Data Store Write blocks. If you do not want the Model Transformer to perform a transformation, clear the check box next to the Data Store Memory block.

Click Refactor Model to create a model that contains the transformations. The app creates the transformed model in a folder with the name m2m_<original model name>.

For an example that replaces Data Store blocks in a model, see Improve Model Readability by Eliminating Local Data Store Blocks.

Transform Table Lookup Blocks to Prelookup and Interpolation Using Prelookup Blocks

Select Transform table lookup into prelookup and interpolation to identify n-D Lookup Table blocks to transform into shared Prelookup blocks and Interpolation Using Prelookup blocks. Eliminating redundant Prelookup blocks in a model improves the simulation speed for linear interpolation.

The Model Transformer identifies where multiple n-D Lookup Table blocks:

  • Use the same input signal for the Lookup Table blocks

  • Have the same breakpoint specification, values, and data types

  • Have the same algorithm parameters in the block parameters dialog box

  • Have the same data type for fraction parameters

After you run this transformation, the Result table displays the identified blocks, their algorithm parameters, and the model, libraries, and referenced models. Select the blocks you want to transform, then click Run This Check.

For an example about the transformation, see Improve Efficiency of Simulation by Optimizing Prelookup Operation of Lookup Table Blocks. For more information about n-D Lookup Table blocks, see n-D Lookup Table.

Replace Interpolation Using Prelookup Blocks

Select Common source interpolation transform to identify multiple Interpolation Using Prelookup blocks that qualify for transformation with a single Interpolation Using Prelookup block. Eliminating the redundant Interpolation Using Prelookup blocks improves the code efficiency of the model.

The Model Transformer identifies when a model contains multiple Interpolation Using Prelookup that:

  • Have the same input signals connected to Prelookup blocks with the same index and fraction parameters

  • Have the output signals connected to the same switch block

  • Have the same breakpoint specification, values, and data types

  • Have the same algorithm parameters

  • Have the same data type for fraction parameters

The Model Transformer app works if the properties of Interpolation Using Prelookup blocks are same except for Table data.

After you run this transformation, the Result table displays the identified blocks, their algorithm parameters, and the model, libraries, and referenced models. Select the blocks you want to transform, then click Run This Check.

For an example about the transformation, see Improve Code Efficiency by Merging Multiple Interpolation Using Prelookup Blocks. For more information about Interpolation Using Prelookup blocks, see Using the Prelookup and Interpolation Blocks.