| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop |
| Contents | Index |
| Learn more about Real-Time Workshop |
The Real-Time Workshop product defines four storage classes for tunable parameters. You must declare a tunable parameter to have one of the following storage classes:
SimulinkGlobal (Auto): This is the default storage class. The Real-Time Workshop product stores the parameter as a member of model_P. Each member of model_P is initialized to the value of the corresponding workspace variable at code generation time.
ExportedGlobal: The generated code instantiates and initializes the parameter and model.h exports it as a global variable. An exported global variable is independent of the model_P data structure. Each exported global variable is initialized to the value of the corresponding workspace variable at code generation time.
ImportedExtern: model_private.h declares the parameter as an extern variable. Your code must supply the proper variable definition and initializer.
ImportedExternPointer: model_private.h declares the variable as an extern pointer. Your code must supply the proper pointer variable definition and initializer, if any.
The generated code for model.h includes model_private.h to make the extern declarations available to subsystem files.
As an example of how the storage class declaration affects the code generated for a parameter, consider the next figure.

The workspace variable Kp sets the gain of the Gain1 block. Assume that the value of Kp is 3.14. The following table shows the variable declarations and the code generated for the gain block when Kp is declared as a tunable parameter. An example is shown for each storage class.
Note The Real-Time Workshop product uses column-major ordering for two-dimensional signal and parameter data. When interfacing your hand-written code to such signals or parameters by using ExportedGlobal, ImportedExtern, or ImportedExternPointer declarations, make sure that your code observes this ordering convention. |
The symbolic name Kp is preserved in the variable and field names in the generated code.
Storage Class | Generated Variable Declaration and Code |
|---|---|
SimulinkGlobal (Auto) | typedef struct _Parameters_tunable_sin
Parameters_tunable_sin;
struct _Parameters_tunable_sin {
real_T Kp;
};
Parameters_tunable_sin tunable_sin_P = {
3.14
};
.
.
tunable_sin_Y.Out1 = rtb_u *
tunable_sin_P.Kp;
|
ExportedGlobal | real_T Kp = 3.14; . . tunable_sin_Y.Out1 = rtb_u * Kp; |
ImportedExtern | extern real_T Kp; . . tunable_sin_Y.Out1 = rtb_u * Kp; |
ImportedExtern Pointer | extern real_T *Kp; . . tunable_sin_Y.Out1 = rtb_u * (*Kp); |
![]() | Tunable Parameter Storage | Using the Model Parameter Configuration Dialog Box | ![]() |

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 |