Main Content

rtw.codegenObjectives.Objective class

Package: rtw.codegenObjectives
Superclasses:

Customize code generation objectives

Description

An rtw.codegenObjectives.Objective object creates a code generation objective.

Construction

rtw.codegenObjectives.ObjectiveCreate custom code generation objectives

Methods

addCheckAdd checks
addParamAdd parameters
excludeCheckExclude checks
modifyInheritedParamModify inherited parameter values
registerRegister objective
removeInheritedCheckRemove inherited checks
removeInheritedParamRemove inherited parameters
setObjectiveNameSpecify objective name

Copy Semantics

Handle. To learn how this affects your use of the class, see Copying Objects in the MATLAB® Programming Fundamentals documentation.

Examples

Create a custom objective named Reduce RAM Example. The following code is the contents of the sl_customization.m file that you create.

function sl_customization(cm)
%SL_CUSTOMIZATION objective customization callback

objCustomizer = cm.ObjectiveCustomizer;
index = objCustomizer.addCallbackObjFcn(@addObjectives);
objCustomizer.callbackFcn{index}();

end
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, 'DefaultParameterBehavior', 'Inlined');
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.design.UnconnectedLinesPorts');
addCheck(obj, 'mathworks.design.Update');

%Register the objective
register(obj);

end