addCheck - Add check to code generation objective - MATLAB (original) (raw)
Main Content
Add check to code generation objective
Syntax
Description
addCheck([objective](#mw%5Fd032ecc0-40ea-48f1-ac0b-e4a411b205a9), [checkID](#mw%5F710a5505-a082-434f-8d5c-1c3fb1854378))
adds the specified check to the specified objective in the Code Generation Advisor. When you select the objective, the Code Generation Advisor includes the check, unless another objective with a higher priority excludes the check.
Examples
Create a custom objective named Reduced RAM Example
that runs checks and verifies parameter values to confirm that the model is configured to reduce the RAM used by the generated code.
Create a file sl_customization.m
to contain a callback function that creates the custom objective.
function sl_customization(cm) %SL_CUSTOMIZATION objective customization callback
objCustomizer = cm.ObjectiveCustomizer; index = objCustomizer.addCallbackObjFcn(@addObjectives); objCustomizer.callbackFcn{index}();
end
Create and configure the objective in the addObjectives
function. Set the name of the objective and add checks and parameters to verify. Then register the objective in the Code Generation Advisor.
function addObjectives
% Create the custom objective obj = rtw.codegenObjectives.Objective('ex_ram_1'); setObjectiveName(obj, 'Reduce RAM Example');
% Add parameters to the objective addParam(obj, 'InlineParams', 'on'); addParam(obj, 'BooleanDataType', 'on'); addParam(obj, 'OptimizeBlockIOStorage', 'on'); addParam(obj, 'EnhancedBackFolding', 'on'); addParam(obj, 'BooleansAsBitfields', 'on');
% Add additional checks to the objective % The Code Generation Advisor automatically includes 'Check model % configuration settings against code generation objectives' in every % objective. addCheck(obj, 'mathworks.codegen.CodeInstrumentation'); addCheck(obj, 'mathworks.codegen.UseRowMajorAlgorithm');
%Register the objective register(obj);
end
Input Arguments
Code generation objective, specified as artw.codegenObjectives.Objective
object.
Identifier of check that you want to add, specified as a character vector or string scalar.
Example: 'mathworks.codegen.CodeInstrumentation'
Version History
Introduced in R2009a