Generate scalar inlined parameters as - Express scalar inlined parameter values in the generated code as literals or

        macros - MATLAB ([original](https://www.mathworks.com/help/ecoder/ref/generatescalarinlinedparametersas.html)) ([raw](?raw))

Main Content

Express scalar inlined parameter values in the generated code as literals or macros

Model Configuration Pane: Code Generation / Identifiers

Description

Control expression of scalar inlined parameter values in the generated code. Block parameters appear inlined in the generated code when you set > > to Inlined.

Dependencies

This parameter:

Settings

Literals (default) | Macros

Literals

Generates scalar inlined parameters as numeric constants.

Macros

Generates scalar inlined parameters as variables with#define macros. This setting makes generated code more readable.

Examples

expand all

When you generate efficient code by inlining the numeric values of block parameters (with the configuration parameter Default parameter behavior), you can configure scalar parameters to appear as macros instead of literal numbers. Each macro has a unique name that is based on the name of the corresponding block parameter.

Open the example model sldemo_fuelsys_dd_controller.

sldemo_fuelsys_dd_controller

The model uses these configuration parameter settings:

Set the configuration parameter Generate scalar inlined parameters as to Macros.

set_param('sldemo_fuelsys_dd_controller','InlinedPrmAccess','Macros')

Generate code from the model.

slbuild('sldemo_fuelsys_dd_controller')

Searching for referenced models in model 'sldemo_fuelsys_dd_controller'.

Total of 1 models to build.

Starting build procedure for: sldemo_fuelsys_dd_controller

Successful completion of code generation for: sldemo_fuelsys_dd_controller

Build Summary

Top model targets:

Model Build Reason Status Build Duration

sldemo_fuelsys_dd_controller Information cache folder or artifacts were missing. Code generated. 0h 0m 16.546s

1 of 1 models built (0 models already up to date) Build duration: 0h 0m 17.065s

The header file sldemo_fuelsys_dd_controller_private.h defines several macros that represent inlined (nontunable) block parameters. For example, the macros rtCP_DiscreteFilter_NumCoe_EL_0 and rtCP_DiscreteFilter_NumCoe_EL_1 represent floating-point constants.

file = fullfile('sldemo_fuelsys_dd_controller_ert_rtw',... 'sldemo_fuelsys_dd_controller_private.h'); coder.example.extractLines(file,'#define rtCP_DiscreteFilter_NumCoe_EL_0',... 'rtCP_DiscreteFilter_NumCoe_EL_1',1,1)

#define rtCP_DiscreteFilter_NumCoe_EL_0 (8.7696F) #define rtCP_DiscreteFilter_NumCoe_EL_1 (-8.5104F)

The comments above the macro definitions indicate that the code generated for a Discrete Filter block uses the macros.

coder.example.extractLines(file,'Computed Parameter: DiscreteFilter_NumCoef',... 'Referenced by: ''/Discrete Filter''',1,1)

/* Computed Parameter: DiscreteFilter_NumCoef

Click the hyperlink to navigate to the block in the model.

Tips

Application Setting
Debugging No impact
Traceability Macros
Efficiency Literals
Safety precaution No impact

Programmatic Use

Parameter: InlinedPrmAccess
Type: character vector
Value: Literals | Macros
Default: Literals

Version History

Introduced before R2006a