addParam
向代码生成目标添加参数
说明
示例
创建一个名为 Reduced RAM Example 的自定义目标,该目标运行检查并验证参数值,确认配置模型为生成代码已减少使用 RAM。
创建文件 sl_customization.m 以包含用于创建自定义目标的回调函数。
function sl_customization(cm) %SL_CUSTOMIZATION objective customization callback objCustomizer = cm.ObjectiveCustomizer; index = objCustomizer.addCallbackObjFcn(@addObjectives); objCustomizer.callbackFcn{index}(); end
在 addObjectives 函数中创建和配置目标。设置目标的名称,并添加检查和参数进行验证。然后在代码生成顾问中注册该目标。
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
输入参数
代码生成目标,指定为 rtw.codegenObjectives.Objective 对象。
要添加到目标的参数的名称,指定为字符向量或字符串标量。
要在代码生成顾问中验证的参数值,指定为字符向量或字符串标量。
版本历史记录
在 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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)