You can use the Metrics Dashboard to identify clones across a model hierarchy. Clones are identical MATLAB Function blocks, identical Stateflow charts, and subsystems that have identical block types and connections. Clones can have different parameter settings and values. To replace clones with links to library blocks, you can open the Clone Detector app from the Metrics Dashboard.
Use the Clone Detector app to refactor a model, improve model componentization and readability, and reuse components within a model. In this example, you launch the Clone Detector from the Metrics Dashboard. However, you can also open it by opening the Apps tab and clicking Clone Detector.
In the Architecture section, the blue bar in the Actual Reuse widget indicates the fraction of total number of subcomponents that are linked library blocks. Pause over the Actual Reuse widget to see more information. For this model, 10% of the total number of subcomponents are linked library blocks.
To see more details, click the blue bar.
Throttle Command, and
CheckRange are linked library blocks.
Return to the main dashboard page.
In the Architecture section, the Potential Reuse bar indicates that the model contains clones. Pause over Potential Reuse. For this model, 7% of the subcomponents are clones.
To see more details, click the yellow bar.
Throttle.throttle_estimate are clones of each
To determine whether these clones are candidates for replacement with linked library blocks, click Open Conversion Tool.
The Clone Detector app opens as a new tab in the model.
In the Clone Detection Actions and Results pane, click the Map Clone Groups to Library tab.
There is one clone group. The light blue shading indicates that these clones are similar clones and not exact clones. Similar clones have different parameter settings and values.
Expand the clone group.
This clone group consists of two subcharts.
To determine parameter differences, in the Block Difference column, click View parameter difference.
The subcharts in this clone group call Simulink functions that differ only by the value of the breakpoints parameters in the Lookup Table blocks inside of them.
In the Map Clone Groups to Library tab, for the Library to place clones parameter, use the Browse button to choose a library or specify a new library name. If you specify a new library name, the app creates the library.
Save the model to your working folder and, in the Clone Detector tab, click Replace Clones. The app replaces similar clones with links to masked library subsystems, if possible.
In the Logs tab, click the latest log.
The log contains a message indicating that the clones cannot be replaced with linked library blocks because the data in the Simulink Functions can not be promoted to subchart data.
Close the Metrics Dashboard and the model.
When the Clone Detector app refactors a model to replace clones with links to
library blocks, the app creates a backup folder. The backup folder name has the
m2m_<model name>. If you have a
Test™ license, you can verify the equivalency of the refactored and original
models by clicking Check Equivalency in the Clone
This table contains a list of common tasks that you can address with Simulink Check.
Simplify and debug complex models.
|Highlight Functional Dependencies|
Run Model Advisor checks for compliance with safety standards associated with High-Integrity System Modeling and MAB Control Algorithm Modeling guidelines.
|Check Model Compliance by Using the Model Advisor|
|Write custom Model Advisor checks.||Defining Custom Model Advisor Checks Workflow|
|Create and deploy a custom Model Advisor configuration.||Create and Deploy a Model Advisor Custom Configuration and Use the Model Advisor Configuration Editor to Customize the Model Advisor|
Learn more about using the Metrics Dashboard to collect and view metric data for quality assessment.
|Collect and Explore Metric Data by Using the Metrics Dashboard|
|Configure compliance metrics, add metric thresholds, and customize the Metrics Dashboard layout.||Customize Metrics Dashboard Layout and Functionality|
Use the Model Transformer tool and the Clone Detector app to refactor a model to improve model componentization and readability and enable reuse.
|Transform Model to Variant System and Enable Component Reuse by Using Clone Detection|
|Learn more about how using Simulink products to test models and code, check for design errors, check against standards, measure coverage, and validate the system.||Verification and Validation|