Element-wise multiplication of the input by a constant gain factor
Library
Math Functions / Math Operations
Description
The Gain block multiplies the input signal by a constant gain factor.
You can specify the data type of the gain constant and built-in type promotion rules apply to determine the output data type. Alternatively, the output data type can be made the same as the input type. In case of integer overflow the block supports the option to saturate output values at the output type limits.
The block warns or errors out when an integer output overflows during
simulation. To configure, select Simulink Editor, then
set the Wrap on overflow
or Saturate on overflow
parameter.
Data Type Support
The block supports all data types except Boolean.
Data type support for the block is:
- The input can be a scalar, vector or matrix.
- If the input is a vector or matrix and the Gain is a scalar, the scalar value will apply to all the elements of the input.
- If neither the input nor the gain constant are scalar the dimensions of the input and the gain constant must match.
The output is complex if either the Gain
constant or the
input is complex.
Parameters
- Gain
- Specifies the constant gain factor. The
Gain
can be any valid MATLAB expression that evaluates to a real or complex scalar, vector, or matrix. - Gain data type
- This parameter specifies the type of conversion to be applied to the
Gain
factor constant before multiplication. Iffixed
is specified more parameters are available.Settings for the
Gain data type
parameter are:Table 1. Gain Data Type Parameter Setting Description double double precision floating-point single single precision floating-point int8 8-bit signed integer uint8 8-bit unsigned integer int16 16-bit signed integer uint16 16-bit unsigned integer int32 32-bit signed integer uint32 32-bit unsigned integer fixed fixed-point half half precision floating-point data type expression A string that specifies the output data type. See "Working with Data Type Expression" in the Vitis Model Composer User Guide (UG1483).
- Output data type same as input
- This parameter specifies the way the output data type is determined.
If disabled (unchecked) the output type is computed via built-in type promotion rules. If enabled (checked), the output data type is the same as the input type.
- Saturate on integer overflow
- This parameter specifies the behavior in case of integer overflow. By default the option is
disabled and overflow would result in value wrap. With the option enabled, integer overflow
gets mitigated by saturation at the limits of the output data type.
Settings for the
Saturate on integer overflow
parameter are:Table 2. Saturate On Integer Overflow Parameter Setting Description Unchecked Wrap around Checked Saturation
When overflow is detected, the Diagnostic Viewer displays messages that depend
on the diagnostic action you specify in the Simulink
Editor. To configure, select for your model in the Simulink Editor, then
set the Wrap on overflow
or Saturate on overflow
parameter.