Use the Model Transformer tool to refactor a model to implement variants, eliminate eligible data store blocks, and improve the simulation efficiency of table lookup operations. You can perform the steps in the Model Transformer all at once or one step at a time.
Use the Model Transformer tool to create models that contain these transformations:
Replace qualifying modeling patterns with variant blocks.
Replace data store blocks with blocks that make data dependency explicit.
Replace n-D Lookup Table blocks with shared Prelookup blocks and multiple Interpolation blocks.
If you want to perform the transformations at once, 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.
Click the Run This Check button to identify system constants for 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 Subsystems and each If Action Subsystem has one outport, replace this modeling pattern with a subsystem and a Variant Source block.
If an If block connects to an If Action Subsystem that has no outport or two or more outports, replace this modeling pattern with a Variant Subsystem block.
If a Switch Case block connects to one or more Switch Case Action Subsystems and each Switch Case Action Subsystem has one outport, replace this modeling pattern with a subsystem and a Variant Source block.
If a Switch Case block connects to a Switch Case Action Subsystem that has no outport or two or more outports, 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.
A system constant is the control input or is 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. The control input must be Constant blocks and some combination of blocks that form a supported MATLAB expression. In the Constant block parameters dialog box, the Constant value parameters are the system constants. In the transformed model, system constants are part of condition expressions in Variant Source or Variant Subsystem blocks.
For some model patterns and settings, the Model Transformer cannot perform every one of the preceding transformations.
In the Result table, each modeling pattern is 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 qualifying pattern.
Click the Refactor Model button to create a model that
contains the transformations. The transformed model is in the folder that has the
prefix m2m
plus the original model name.
Click the Run This Check button 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, aDelay block, or a Merge
block. The model is in the folder that has the prefix m2m
plus
the original model name.
Replacing these blocks improves model readability by making 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 tool 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 tool replaces these blocks with a direct connection.
For bus signals, if the write to bus elements executes before the read of the bus, the tool 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 tool replaces the Data Store Read and Data Store Write blocks with a direct connection and a Bus Selector block.
For conditionally executed subsystems, the tool replaces the Data Store Read and Data Store Write blocks with a direct connection and a Merge block.
The Model Transformer tool only eliminates local data stores that Data Store Memory blocks define. The tool 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.
The Result table contains 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, before clicking the Refactor Model button, clear the check box next to the Data Store Memory block.
To identify n-D Lookup Table blocks that qualify for transformation into shared Prelookup blocks and multiple Interpolation blocks, click the Run This Check button. The tool displays the identified blocks and their algorithm parameters along with the model, libraries, and referenced models. You can also clear the blocks for transformation.
The Model Transformer works if:
The same source drives the Lookup Table blocks.
The Lookup table blocks share the same breakpoint specification, values, and data types.
The Lookup table blocks share the same algorithm parameters in the block parameters dialog box.
The Lookup table blocks share the same data type for fractions parameters in the block parameters dialog box.
To create a model that replaces these Lookup Table blocks with a shared Prelookup and Interpolation blocks, click the Run This Check button.
Eliminating the redundant Prelookup blocks in the equivalent model generated improves the simulation speed for linear interpolations.