register
Register objective in Code Generation Advisor
Syntax
Description
Examples
Create a Custom Code Generation Objective
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
objective
— Code generation objective
rtw.codegenObjectives.Objective
object
Code generation objective, specified as a
rtw.codegenObjectives.Objective
object.
Version History
Introduced in R2009a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)