With Simulink® Check™, you can use the Model Transformer and Identify Modeling Clones tools to refactor a model to improve model componentization and enable reuse.
You can use the Identify Modeling Clones tool to enable component reuse by completing these tasks:
Identify subsystem clones.
Create library blocks from clones.
Create a model that replaces clones with links to library blocks.
Identify similar clones.
In the Simulink Editor, from the Analysis
menu, select Refactor Model > Identify Modeling Clones. To open the Identify Modeling Clones tool
programmatically, at the MATLAB command prompt type:
Open the Identify Modeling Clones folder.
Select Identify library clones and replace them with links
to library blocks. In the Library file
name field, insert the library name,
Select Identify similar library clones. In the
Library file name field, insert the library
Select Identify Modeling Clones folder. Then, click Run Selected Checks. Because every check is selected by default, the tool identifies all possible clones in the model.
Select each check. The checks contain hyperlinks to the clones in the model.
Each check in the Identify Exact Clones folder contains a Refactor Model button. To replace clones with links to library blocks, you must complete each check and click Refactor Model. You cannot simultaneously run selected checks and refactor the model.
To improve model componentization by replacing qualifying modeling patterns with Variant Source and Variant Subsystem blocks, use the Model Transformer tool.
ex_variants_transformer model contains several modeling
patterns that qualify for transformation into variants blocks.
Open the example model
Save the model to your working folder.
From the Simulink Editor, open the Model Transformer tool by selecting Refactor Model > Model Transformer. Or, in the Command Window, type:
Select the Model Transformer folder. To run selected steps, click the Run Selected Checks button. The tool identifies qualifying modeling patterns and creates a model containing Variant blocks.
Click Run Selected Checks.
Your working folder contains a folder called
m2m_ex_variants_transformer. This folder contains the
Click the Convert blocks to variants folder.
The Results section contains hyperlinks to the original and transformed models.