Documentation Center

  • Trial Software
  • Product Updates

Simulink.Parameter

Specify value, value range, data type, and other properties of block parameter

Description

This class enables you to create workspace objects that you can then use as the values of block parameters — for example, the value of the Gain parameter of a Gain block. You can create a Simulink.Parameter object in the base MATLAB® workspace or a model workspace. However, to create the object in a model workspace, you must set the object storage class to Auto.

Parameter objects let you specify not only the value of a parameter but also other information about the parameter, such as the parameter's purpose, its dimensions, or its minimum and maximum values. Some Simulink® products use this information. For example, Simulink and Simulink Coder™ products use information specified by Simulink.Parameter objects to determine whether the parameter is tunable (see Tunable Parameters).

Simulink performs range checking of parameter values. The software alerts you when the parameter object value lies outside a range that corresponds to its specified minimum and maximum values and data type.

You can use the Simulink.Parameter dialog box to define a Simulink.Parameter object. To open the dialog box, in the Model Explorer, select the base workspace or a model workspace and select Add > Simulink Parameter.

Property Dialog Box

Value

Value of the parameter. You can use MATLAB expressions to specify the numeric type, dimensions, and data type of the parameter (see Data Types Supported by Simulink). You can also specify fixed-point values for block parameters (see Specify Fixed-Point Values Directly in the Fixed-Point Designer™ documentation). The following examples illustrate this syntax.

ExpressionDescription
single(1.0)

Specifies a single-precision value of 1.0

int8(2)

Specifies an 8-bit integer of value 2

int32(3+2i)

Specifies a complex value whose real and imaginary parts are 32-bit integers

fi(2.3,true,16,3)

Specifies a signed fixed-point numeric object having a value of 2.3, a word length of 16 bits, and a fraction length of 3.

(Requires Fixed-Point Designer)

struct('A',20,'B',5)

Specifies a structure for a bus with two signals, A and B, with double-precision values of 20 and 5, respectively.

The shape and attributes of the structure must match the shape and attributes of the elements in the bus. For information about specifying an initial condition structure, see Specify Initial Conditions for Bus Signals.

    Note:   Specifying a typed expression as the Value property of the parameter object overrides the current setting of the Data type property.

If Value evaluates to a MATLAB structure, then in the Configuration Parameters > Diagnostics > Data Validity pane, set Underspecified initialization detection to simplified.

Data type

Data type of the parameter. You can either select a data type from the adjacent pulldown menu or enter a string. If you select auto (the default), the block that references the parameter object determines the data type of the variable used to represent this parameter in code generated from the model. If you enter a string, it must evaluate to one of the following:

  • A built-in data type that Simulink supports (see Data Types Supported by Simulink ).

  • A Simulink.NumericType object

  • A Simulink.AliasType object

  • A Simulink.Bus object (using the Bus: <object name> option)

    You can use the Bus Editor to define or edit a Simulink.Parameter object with a bus object for its data type. Use one of these approaches:

    • Select the File > Create/Edit a Simulink.Parameter object menu item.

    • Click the Create/Edit a Simulink.Parameter object icon ( ) from the toolbar.

    You can then edit the Simulink.Parameter object in the MATLAB Editor and evaluate the code to create or update the values for this Simulink.Parameter object.

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Data type parameter. (See Specify Data Types Using Data Type Assistant.)

    Note:   If you specify a parameter object data type using the Data type property, it overrides any typed expression in the Value property and changes the value to be untyped.

Units

Measurement units in which this value is expressed (for example, inches). This field is intended for use in documenting this parameter. Simulink ignores it.

Dimensions

Dimensions of the parameter. Simulink determines the dimensions from the entry in the Value field of this parameter. You cannot set this field yourself.

Complexity

Numeric type (i.e., real or complex) of the parameter. Simulink determines the numeric type of this parameter from the entry in the Value field of this parameter. You cannot set this field yourself.

Minimum

Minimum value that the parameter can have. The default value is [] (unspecified). Specify a finite, real, double, scalar value.

    Note:   If you specify a bus object as the data type for a parameter, do not set the minimum value for bus data on the parameter property dialog box. Simulink ignores this setting. Instead, set the minimum values for bus elements of the bus object specified as the data type. For information on the Minimum property of a bus element, see Simulink.BusElement.

Simulink generates a warning if the parameter value is less than the minimum value or if the minimum value is outside the range of the parameter data type. When updating the diagram or starting a simulation, Simulink generates an error in these cases.

Maximum

Maximum value that the parameter can have. The default value is [] (unspecified). Specify a finite, real, double, scalar value.

    Note:   If you specify a bus object as the data type for a parameter, do not set the maximum value for bus data on the parameter property dialog box. Simulink ignores this setting. Instead, set the maximum values for bus elements of the bus object specified as the data type. For information on the Maximum property of a bus element, see Simulink.BusElement.

Simulink generates a warning if the parameter value is greater than the maximum value or if the maximum value is outside the range of the parameter data type. When updating the diagram or starting a simulation, Simulink generates an error in these cases.

Storage class

Storage class of this parameter. Simulink code generation products use this property to allocate memory for this parameter in generate code. For more information, see Tunable Parameter Storage Classes.

Alias

Alternate name for this parameter. Simulink ignores this setting.

Alignment

Data alignment boundary, specified in number of bytes. The starting memory address for the data allocated for the parameter will be a multiple of the Alignment setting. The default value is -1, which specifies that the code generator should determine an optimal alignment based on usage. Otherwise, specify a positive integer that is a power of 2, not exceeding 128. This field is intended for use by Simulink Coder software (see Configure Data Alignment for Function Implementations). Simulink software ignores this setting.

Description

Description of this parameter. This field is intended for use in documenting this parameter. Simulink ignores it.

Properties

Name

Access

Description

Value

RW

Value of this parameter. (Value)

CoderInfo

R

Information used by Simulink Coder software for generating code for this parameter. The value of this property is an object of Simulink.ParamCoderInfo class.

Description

RW

String that describes this parameter. This property is intended for user use. Simulink itself does not use it. (Description)

DataType

RW

String specifying the data type of this parameter. (Data type)

Min

RW

Minimum value that this parameter can have. (Minimum)

Max

RW

Maximum value that this parameter can have. (Maximum)

DocUnits

RW

Measurement units in which this parameter's value is expressed. (Units)

Complexity

RO

String specifying the numeric type of this parameter. Valid values are 'real' or 'complex'. (Complexity)

Dimensions

RO

Vector specifying the dimensions of this parameter. (Dimensions)

Was this topic helpful?