Identify Modeling Clones with the Metrics Dashboard
You can use the Metrics Dashboard tool to help you reuse subsystems by identifying clones across a model hierarchy. Clones are identical MATLAB Function blocks, identical Stateflow® charts, and subsystems that have identical block types and connections. The clones can have different parameter settings and values. To replace clones with links to library blocks, from the Metrics Dashboard, you can open the Clone Detector app.
ex_clone_detection.slxmodel to a local working folder.
On the Apps tab, click Metrics Dashboard.
In the Metrics Dashboard, click All Metrics.
In the Architecture section, the yellow bar in the Potential Reuse row indicates that the model contains clones. The percentage is the fraction of the total number of subsystems, including Stateflow charts and MATLAB Function blocks, that are clones. To see details, click the yellow bar.
The model contains three clone groups.
SS4 are part of clone group one.
SS5 are part of clone group two.
SS7 are part of clone group three.
Replace Clones with Links to Library Blocks
Open the Clone Detector app by clicking Open Conversion Tool. The Clone Detector app opens. For more information on the app, see Enable Component Reuse by Using Clone Detection.
Click Replace Clones. The Clone Detector app replaces the clones with links to library blocks. The library blocks are in the library specified by the Library to place clones parameter. This parameter is on the Clone Results tab. The library is on the MATLAB® path. It has a default name of
If you have a Simulink® Test™ license, you can verify the equivalency of the refactored model and the original model. Click Check Equivalency.
Run Model Metrics on the Refactored Model
Navigate to the Metrics Dashboard.
Click All Metrics.
In the Architecture section, the blue bar in the Actual Reuse row indicates that 75% of model components are links to library subsystems. The Potential Reuse row indicates that the model does not contain any clones that do not have links to library blocks.