Main Content

setRecAction

Add Recommended Action text in Model Advisor analysis results

Description

setRecAction(ftObj,recActionText) is an optional method to add a Recommended Action section to the report created by the Model Advisor formatting object ftObj. Use this method to describe how to fix the check.

example

Examples

collapse all

This example shows how to search for all Gain blocks in the current model, check if their gain value evaluates to 1, and provide a recommendation in the Model Advisor report.

Create a list template object.

ft = ModelAdvisor.FormatTemplate("ListTemplate");

Open the example model vdp.

openExample("vdp");
ans = logical
   1

Find all the gain blocks in the model.

gainBlocks = find_system(gcs,"BlockType","Gain");

Loop through each gain block, resolve its value, and if the gain evaluates to 1, add a recommendation:

for idx = 1:length(gainBlocks)
    gainObj = get_param(gainBlocks{idx},"Object");
    resGain = slResolve(gainObj.Gain, gainObj.getFullName);
    if ~isempty(resGain) && any(resGain == 1)
        setRecAction(ft,{"Replace Gain blocks with value 1 with Signal Conversion blocks."});
        break; % Add recommendation only once if any such block is found
    end
end

Input Arguments

collapse all

ModelAdvisor.FormatTemplate object, specified as a handle to the formatting template.

Cell array of character vectors or handles to formatting objects, that describes the Recommended Action to fix the issues reported by the check. The Model Advisor displays the Recommended Action as a separate section below the list or table in the report.

Example: {"Replace these blocks with Signal Conversion blocks."}

Version History

Introduced in R2009a