Main Content

Simulink.CloneDetection.addExclusions

Exclude component from clone detection

Since R2025a

Description

excludeResults = Simulink.CloneDetection.addExclusions(modelName,query,rationale) excludes components, such as subsystems or referenced models, specified by query from clone detection analysis for the model modelName with a rationale specified by rationale.

Examples

collapse all

Exclude blocks from clone detection analysis.

Open the model ex_detect_clones.

openExample('ex_detect_clones')

Exclude the subsystems SS2 and SS3 in the model ex_detect_clones from clone detection analysis.

exclusionResults = Simulink.CloneDetection.addExclusions('ex_detect_clones',...
               {'ex_detect_clones/SS2','ex_detect_clones/SS3'},'Block to be removed later.')
exclusionResults =

  struct with fields:

    AddedExclusions: [1×2 struct]
    FailedExclusions: []

View the first added exclusion:

exclusionResults.AddedExclusions(1)
ans =

  struct with fields:

        Query: ''
        Block: 'ex_detect_clones/SS2'
    Rationale: 'Block to be removed later.'

Exclude blocks using specific criteria from clone detection analysis.

Open the model ex_detect_clones.

openExample('ex_detect_clones')

Exclude virtual subsystems in the model ex_detect_clones from clone detection analysis.

exclusionResults = Simulink.CloneDetection.addExclusions('ex_detect_clones',...
           {'BlockType','Subsystem','IsSubsystemVirtual','On'},'Virtual subsystems excluded.')
exclusionResults =

  struct with fields:

    AddedExclusions: [1×1 struct]
    FailedExclusions: []

This defines the criteria for exclusion based on a BlockType of Subsystem and the property IsSubsystemVirtual is On, indicating that the subsystem is virtual.

View the added exclusions:

exclusionResults.AddedExclusions(1)
ans =

  struct with fields:

        Query: 'BlockType,Subsystem,IsSubsystemVirtual,On'
        Block: ''
    Rationale: 'Virtual subsystems excluded.'

Simulink.CloneDetection.addExclusions adds a query to exclude virtual subsystems from clone detection analysis. The function is capable of handling queries that the function find_system supports.

Input Arguments

collapse all

Model to add the exclusion, specified as a character vector or string scalar.

Example: 'mymodel'

Data Types: char | string

Blocks or query to be excluded from clone detection analysis, specified as a cell array of character vectors.

Example: {'Subsystem1','Subsystem2'}

Example: {'BlockType','Subsystem','IsSubsystemVirtual','On'}

Data Types: cell

Reason for exclusion, specified as a character vector or string array.

Example: 'Block to be removed later.'

Data Types: char | string

Output Arguments

collapse all

Results of the exclusion operation, returned as a structure with these fields:

Exclusions that are added, returned as a structure with these fields:

FieldDescription
QueryQuery used to exclude blocks
BlocksBlocks excluded from clone analysis
RationaleRational for exclusion

Exclusions that are not added, returned as a structure with these fields:

FieldDescription
ExcludedBlockOrQueryBlocks or query used to exclude blocks
ExclusionReasonRational for exclusion

Alternative Functionality

Clone Detection Exclusion Editor

You can also manage exclusions by using the Clone Detection Exclusion Editor. To add an exclusion from the Simulink® model, right-click a Subsystem or Model block and select Identify Modeling Clones > Open Clone Detection Exclusion Editor. For more information, see Exclude Components from Clone Detection.

Version History

Introduced in R2025a