To save time during model development and verification, you can limit the scope of a Model Advisor analysis of your model. You can create a Model Advisor exclusion to exclude blocks in the model from selected checks. You can exclude all or selected checks from:
Simulink® blocks
Stateflow® charts
After you specify the blocks to exclude, Model Advisor uses the exclusion information to exclude blocks from specified checks during analysis. By default, Model Advisor exclusion information is stored in the model SLX file. Alternately, you can store the information in an exclusion file.
To view exclusion information for the model, right-click in the model window or right-click a block and select Model Advisor > Open Model Advisor Exclusion Editor.
The Model Advisor Exclusion Editor dialog box includes the following information for each exclusion.
Field | Description |
---|---|
Rationale | A description of why this object is excluded from Model Advisor checks. The rationale field is the only field that you can edit. |
Type | Whether a specific block is excluded or all blocks of a given type are excluded. |
Value | Name of excluded block or blocks. |
Check ID (s) | Names of checks for which the block exclusion applies. |
If you comment out blocks, they are excluded from both simulation and Model Advisor analysis.
To save Model Advisor exclusions to the model .slx
file, in the
Model Advisor Exclusion Editor dialog box, select Store exclusions in model
file. When you open the model .slx
file, the model
contains the exclusions.
A Model Advisor exclusion file specifies the collection of blocks to exclude from specified checks in an exclusion file. You can create exclusions and save them in an exclusion file. To use an exclusion file, in the Model Advisor Exclusion Editor dialog box, clear Store exclusions in model file. The Exclusion File field is enabled.
The Exclusion File contains the exclusion file name and location associated with the model. You can use an exclusion file with several models. However, a model can have only one exclusion file.
Unless you specify a different folder, the Model Advisor saves exclusion files in the
current folder. The default name for an exclusion file is
<
. model_name
>_exclusions.xml
If you create an exclusion file and save your model, you attach the exclusion file to your model. Each time that you open the model, the blocks and checks specified in the exclusion file are excluded from the analysis.
In the model window, right-click a block and select Model Advisor. Select the menu option for the type of exclusion that you want to do.
To | Select Model Advisor > |
---|---|
Exclude the block from all checks. | Exclude block only > All Checks |
Exclude all blocks of this type from all checks. | Exclude all blocks with type <block_type> > All Checks |
Exclude the block from selected checks. |
|
Exclude all blocks of this type from selected checks. |
|
Exclude the block from all failed checks. After a Model Advisor analysis, this option is available. | Exclude block only > Only failed checks |
Exclude all blocks of this type from all failed checks. After a Model Advisor analysis, this option is available. | Exclude all blocks with type <block_type> > Only failed checks |
Exclude the block from a failed check. After a Model Advisor analysis, this option is available. | Exclude block only > <name of failed check> |
Exclude all blocks of this type from a failed check. After a Model Advisor analysis, this option is available. | Exclude all blocks with type <block_type> > <name of failed check> |
In the Model Advisor Exclusion Editor dialog box, to:
Store exclusions in model file, select Store exclusions in model file. Click OK or Apply to create the exclusion.
Save the information to an exclusion file, clear Store
exclusions in model file. Click
OK or Apply. If
this exclusion is the first one, a Save Exclusion File as dialog box
opens. In this dialog box, click Save to
create a exclusion file with the default name
<
in the current folder. Optionally, you can select a different file
name or location.model_name
>_exclusions.xml
Optionally, if you want to change the exclusion file name or location:
In the Model Advisor Exclusion Editor dialog box, clear Store exclusions in model file.
In the Model Advisor Exclusion Editor dialog box, select Change.
In the Change Exclusion File dialog box, select Save as.
In the Save Exclusion File dialog box, navigate to the location that you want and enter a file name. Click Save.
In the Model Advisor Exclusion Editor dialog box, select OK or Apply to create the exclusion and save the information to an exclusion file.
You can create as many Model Advisor exclusions as you want by right-clicking model blocks and selecting Model Advisor. Each time that you create an exclusion, the Model Advisor Exclusion Editor dialog box opens. In the Rationale field, you can specify a reason for excluding blocks or checks from the Model Advisor analysis. The rationale is useful to others who review your model.
If you create an exclusion file and save your model, you attach the exclusion file to your model. Each time that you open the model, the blocks and checks specified in the exclusion file are excluded from the analysis.
You can review the exclusions associated with your model. Before or after a Model Advisor analysis, to view exclusions information:
Right-click in the model window or right-click a block and select Model Advisor > Open Model Advisor Exclusion Editor. The Model Advisor Exclusion Editor dialog box lists the exclusions for your model.
In the Modeling tab, open Model Advisor > Preferences. In the Model Advisor Preferences dialog box, select Show Exclusion tab. In the right pane of the Model Advisor window, select the Exclusions tab to display checks that are excluded from the Model Advisor analysis.
In the Modeling tab, select Model Advisor to open the Model Advisor.
On the Model Advisor window toolbar, select Highlighting > Highlight Exclusions. By default, this menu option is selected.
In the Model Advisor window, click Enable
highlighting ().
After the Model Advisor analysis, you can view exclusion information for individual checks in the:
HTML report. Before the analysis, in the Model Advisor window, make sure that you select the Show report after run check box.
After you run the checks, in the left pane of the Model Advisor window, the checks that contain exclusion rules are highlighted in orange. The Model Advisor results include additional information about the exclusion.
If the check | The HTML report and Model Advisor window |
---|---|
Has no exclusions rules applied. | Show that no exclusions were applied to this check. |
Does not support exclusions. | Shows that the check does not support exclusions. |
Is excluded from a block. | Lists the check exclusion rules. |
In the Model Advisor Exclusion Editor dialog box, clear Store
exclusions in model file and click OK
or Apply. If this exclusion is the first one, a Save
Exclusion File as dialog box opens. In this dialog box, click
Save to create an exclusion file with the default
name
<
in the current folder. Optionally, you can select a different file name or
location.model_name
>_exclusions.xml
If you want to change the exclusion file name or location:
In the Model Advisor Exclusion Editor dialog box, select Change.
In the Change Exclusion File dialog box, select Save as.
In the Save Exclusion File dialog box, navigate to the location that you want and enter a file name. Click Save.
In the Model Advisor Exclusion Editor dialog box, select OK or Apply to create the exclusion and save the information in an exclusion file.
To load an existing exclusion file for use with your model:
In the Model Advisor Exclusion Editor dialog box, clear Store exclusions in model file. Click Change.
In the Change Exclusion File dialog box, click Load.
Navigate to the exclusion file that you want to use with your model. Select Open.
In the Model Advisor Exclusion Editor dialog box, click OK to associate the exclusion file with your model.
To detach an exclusion file associated with your model:
In the Model Advisor Exclusion Editor dialog box, clear Store exclusions in model file. Click Change.
In the Change Exclusion File dialog box, click Detach.
In the Model Advisor Exclusion Editor dialog box, click OK.
In the Model Advisor Exclusion Editor dialog box, select the exclusions that you want to remove.
Click Remove Exclusion.
You can add text that describes why you excluded a particular block or blocks from selected checks during Model Advisor analysis. A description is useful to others who review your model.
In the Model Advisor Exclusion Editor dialog box, double-click the Rationale field for the exclusion.
Delete the existing text.
Add the rationale for excluding this object.
You can use the MAModelExclusionFile
method to programmatically
specify the name of an exclusion file.
Use get_param
to obtain the model object. For example,
for
sldemo_mdladv
:
mo = get_param('sldemo_mdladv','Object')
Use MAModelExclusionFile
to specify the name of an
exclusion file. For example, to specify exclusion file
my_exclusion.xml
in
S:\work
:
mo.MAModelExclusionFile = ['S:\work\','my_exclusion.xml']
Open the Model Advisor Exclusion Editor dialog box. The Exclusion File field contains the specified exclusion file and path.
While editing a model, you can exclude blocks from Model Advisor analysis. Applicable Model Advisor exclusions specified through the Simulink editor are also applied during edit-time.
To exclude a block from Model Advisor analysis during edit-time:
From the command prompt, open sldemo_fuelsys
.
Introduce a warning that is visible in edit-time checking. Add the number
9
to the beginning of the Engine Speed
block name, which results in a violation of Model Advisor check Check character usage in block names.
In the Modeling tab, select Edit-Time Checks. Multiple blocks are flagged as Model Advisor check violations.
For instance, the Engine Speed block is highlighted and,
when you click the warning icon above the block, you see that the cause of
the violation is Block name has incorrect characters
.
To exclude the Engine Speed block from Model Advisor analysis, either:
Right-click the block, select Model Advisor > Exclude block only > Select checks, and select the check.
Click the warning icon above the highlighted Engine Speed block. In the diagnostic window, select Suppress.
The block is excluded from Model Advisor analysis for that check and is not highlighted for check violation.
The list of exclusions is shared between all executions of the Model Advisor checks.
This example shows how to exclude a Gain block and all Outport blocks from a Model Advisor check during a Model Advisor analysis. By excluding individual blocks from checks, you limit the scope of the analysis and might save time during model development and verification.
At the MATLAB® command line, type sldemo_mdladv
.
From the model window, in the Modeling tab, select Model Advisor to open the Model Advisor. A System Selector - Model Advisor dialog box opens. Click OK.
In the left pane of the Model Advisor window, expand By Product > Simulink. Select the Show report after run check box to see an HTML report of check results after you run the checks.
If the By Product folder is not displayed in the Model Advisor window, select Show By Product Folder from the Settings > Preferences dialog box.
Run the selected checks by clicking the Run selected checks button. After the Model Advisor runs the checks, an HTML report displays the check results in a browser window. The check Identify unconnected lines, input ports, and output ports triggers a warning.
In the left pane of the Model Advisor window, select the check By Product > Simulink > Identify unconnected lines, input ports, and output ports.
In the Model Advisor window, click the Enable
highlighting button ().
The model window opens. The blocks causing the Identify unconnected lines, input ports, and output ports check warning are highlighted in yellow.
The Model Advisor Highlighting window opens with a link to the Model Advisor window. In the Model Advisor window, you can find more information about the check results and how to fix the warning condition.
After reviewing the check results, exclude the Gain2 block from all Model Advisor checks:
In the model window, right-click the Gain2 block and select Model Advisor > Exclude block only > All checks .
In the Model Advisor Exclusion Editor dialog box, double-click
in the first row of the Rationale field,
and enter Exclude gain block
.
Click OK to store the exclusion in the model file.
After reviewing the check results, exclude all Outport blocks from the Identify unconnected lines, input ports, and output ports check:
Right-click the Out4 block and select Model Advisor > Exclude all blocks of type Outport > Identify unconnected lines, input ports, and output ports.
In the Model Advisor Exclusion Editor dialog box, click OK to store the exclusion in the model file.
In the left pane of the Model Advisor window, select By Product > Simulink and then:
Select the Show report after run check box.
Click Run Selected Checks to run a Model Advisor analysis.
After the Model Advisor completes the analysis, you can view exclusion information for the Identify unconnected lines, input ports, and output ports check in the:
HTML report:
Model Advisor window. In the left pane of the Model Advisor window, select By Product > Simulink > Identify unconnected lines, input ports, and output ports.
Close sldemo_mdladv
.