Code Generation of Parameter Objects With Expression Values - MATLAB & Simulink (original) (raw)

As described in Set Variable Value by Using a Mathematical Expression, you can set the value of a Simulink.Parameter object to an expression involving other MATLABĀ® variables or parameter objects. When you generate code from a model that uses such a parameter object, to achieve your goal, use the information in the table.

Goal Technique and More Information
Generate code without Embedded CoderĀ®. For the parameter object that uses the expression, apply an available storage class (see C Data Code Interface Configuration for Model Interface Elements).For the parameter objects used in the expression, apply only the storage classAuto.
Generate code that defines a global variable and initializes it by using an expression involving system constants and other macros (requires Embedded Coder). See Initialize Parameter Value From System Constant or Other Macro (Embedded Coder) (Embedded Coder).
Generate code that defines a macro whose value is an expression involving other macros (requires Embedded Coder). For the parameter object that uses the expression, apply a storage class that yields a macro in the generated code, such as Define (seeMacro Definitions (#define) (Embedded Coder)).For the parameter objects used in the expression, apply storage classes that yield imported macros. For example, use the storage class ImportedDefine. Your external code must define these macros.

Considerations and Limitations

Expression Preservation

If you want Embedded Coder to preserve expressions in the generated code, adhere to these restrictions and guidelines.

See Also

Simulink.Parameter

Topics