Documentation

Specify Minimum and Maximum Values for Block Parameters

You can protect your model design by preventing block parameters from using values outside of a range. For example, if the value of a parameter that represents the angle of an aircraft aileron cannot feasibly exceed a known magnitude, you can specify a design maximum for the parameter in the model.

Fixed-Point Designer™ enables Simulink® to use your range information to calculate best-precision fixed-point scaling for:

  • Tunable parameters.

  • Signals, by taking into consideration the range of values that you intend to assign to tunable parameters.

For basic information about block parameters, see Set Block Parameter Values.

Specify Block Parameter Value Ranges

To specify a value range for a block parameter, choose a technique based on your modeling goals.

  • You can specify value ranges for some block parameters by using other parameters of the same block. For example, you can control the value range of the Gain parameter of a Gain block by using the Parameter minimum and Parameter maximum parameters in the Parameter Attributes tab in the block dialog box. For other blocks, such as n-D Lookup Table and PID Controller, use the Data Types tab.

    Use this technique to:

    • Store the range information in the model file.

    • Store the range information when you store fixed-point data type information in the block (for example, by setting the Parameter data type parameter of a Gain block to a fixed-point type, including best-precision scaling). This technique more clearly associates the range information with the data type information.

  • To specify value ranges for the parameters of any block, consider using parameter objects (for example, Simulink.Parameter) to set the parameter values. You can specify the range information in the object, instead of the block, by using the Min and Max properties.

    Use this technique to:

    • Specify range information for blocks that cannot store minimum or maximum information, for example, many blocks in the Continuous library.

    • Specify range information for a single value that you share between multiple block parameters (see Share and Reuse Block Parameter Values by Creating Variables). Instead of using a numeric MATLAB® variable, use a parameter object so that you can specify the Min and Max properties.

    • Store the range information when you store fixed-point data type information in a parameter object (by setting the DataType property to a fixed-point type instead of auto). This technique more clearly associates the range information with the data type information.

    If you specify the range information in a parameter object, consider removing the range information from the block. For example, on the Parameter Attributes tab of a Gain block dialog box, set Parameter minimum and Parameter maximum to []. Some tools, such as the Fixed-Point Tool, use the range information that you specify in the block only if you do not specify the range information in the parameter object. If you specify the range information in the parameter object, the tools ignore the range information that you specify in the block.

    For basic information about creating and using data objects, see Data Objects.

Specify Valid Range Information

The minimum and maximum values that you specify for a parameter must evaluate to a finite, scalar, real number that uses the data type double. For example, you can set the Parameter minimum parameter of a Gain block to a literal number such as 15.23, or to the name of a workspace variable whose value is 15.23. Use a workspace variable to apply the same minimum or maximum to multiple block parameters. However, you cannot use variables to set the Min or Max properties of a parameter object.

To leave the minimum or maximum of a block parameter or parameter object unspecified, use an empty matrix [], which is the default value.

Specify Range Information for Nonscalar Parameters

If the value of a block parameter is a vector or matrix, the range information that you specify applies to each element of the vector or matrix. If the value of any of the elements is outside the specified range, the model generates an error.

If the value of a block parameter is a structure or a field of a structure, specify range information for the structure fields by creating a Simulink.Parameter object whose data type is a Simulink.Bus object. Specify the range information by using the properties of the signal elements in the bus object. For more information, see Control Field Data Types and Characteristics by Creating Parameter Object.

Specify Range Information for Complex-Valued Parameters

If the value of a block parameter is complex (i), the range information that you specify applies separately to the real part and to the imaginary part of the complex number. If the value of either part of the number is outside the range, the model generates an error.

Restrict Allowed Values for Block Parameters

To protect your design by preventing block parameters from using values outside of a range, you can specify the minimum and maximum information by using other parameters of the same block. If you or your users set the value of the target parameter outside the range that you specify, the model generates an error.

Whether a block allows you to specify a value range for a parameter, consider using a parameter object (for example, Simulink.Parameter) to set the value of the target parameter. Use the properties of the object to specify the range information. This technique helps you to specify range information for a variable that you use to set multiple block parameter values.

Specify Range Information for Tunable Fixed-Point Parameters

When you use fixed-point data types in your model, you can enable Simulink to choose a best-precision scaling for block parameters and Simulink.Parameter objects. If you intend to tune such a parameter by changing its value during simulation or during execution of the generated code, the fixed-point scaling chosen by Simulink must accommodate the range of values that you expect to assign to the parameter.

Also, if you expect to change the value of a parameter, signal data types in the model must accommodate the corresponding expanded range of possible signal values. If you use the Fixed-Point Tool to propose and apply fixed-point data types for a model, to allow the tool to accurately autoscale the signals, specify range information for tunable parameters.

To specify range information for tunable parameters, see Calculate Best-Precision Fixed-Point Scaling for Tunable Block Parameters. To learn how the Fixed-Point Tool autoscales signals by taking into account the value ranges of tunable parameters, see Derive Ranges for Simulink.Parameter Objects.

Related Examples

Was this topic helpful?