Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Nontunable Parameter Storage

By default, block parameters are not tunable in the generated code. When Inline Parameters is off (the default), the Real-Time Workshop product has control of parameter storage declarations and the symbolic naming of parameters in the generated code.

Nontunable parameters are stored as fields within model_P (formerly rtP), a model-specific global parameter data structure. The Real-Time Workshop product initializes each field of model_P to the value of the corresponding block parameter at code generation time.

When the Inline parameters option is on, block parameters are evaluated at code generation time, and their values appear as constants in the generated code, if possible (in certain circumstances, parameters cannot be inlined, and are then included in a constant parameter or model parameter structure.)

As an example of nontunable parameter storage, consider the following model.

The workspace variable Kp sets the gain of the Gain block.

Assume that Kp is nontunable and has a value of 5.0. The next table shows the variable declarations and the code generated for Kp in the noninlined and inlined cases.

The generated code does not preserve the symbolic name Kp. The noninlined code represents the gain of the Gain block as model_P.Gain_Gain. When Kp is noninlined, the parameter is tunable.

Inline ParametersGenerated Variable Declaration and Code
Off
struct Parameters_non_tunable_sin { real_T SineWave_Amp;
		real_T SineWave_Bias;
  			real_T SineWave_Freq;
  			real_T SineWave_Phase;
  			real_T Gain_Gain;
			};
			.
			.
			.
			Parameters_non_tunable_sin non_tunable_sin_P = {
  			1.0 , /* SineWave_Amp : '<Root>/Sine Wave' */
  			0.0 , /* SineWave_Bias : '<Root>/Sine Wave' */
  			1.0 , /* SineWave_Freq : '<Root>/Sine Wave' */
  			0.0 , /* SineWave_Phase : '<Root>/Sine Wave' */
  			5.0   /* Gain_Gain : '<Root>/Gain' */
			};
			.
			.
			.
			non_tunable_sin_Y.Out1 = rtb_u * 
			non_tunable_sin_P.Gain_Gain;
On
non_tunable_sin_Y.Out1 = rtb_u * 5.0;

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS