Simulink Reference Previous page   Next Page
Gain

Multiply the input by a constant

Library

Math Operations

Description

The Gain block multiplies the input by a constant value (gain). The input and the gain can each be a scalar, vector, or matrix.

You specify the value of the gain in the Gain parameter. The Multiplication parameter lets you specify element-wise or matrix multiplication. For matrix multiplication, this parameter also lets you indicate the order of the multiplicands.

The gain is converted from doubles to the data specified in the block mask offline using round-to-nearest and saturation. The input and gain are then multiplied, and the result is converted to the output data type using the specified rounding and overflow modes.

Data Type Support

The Gain block accepts a real or complex scalar, vector, or matrix of any data type supported by Simulink except Boolean. The Gain block supports fixed-point data types. If the input of the Gain block is real and the gain is complex, the output is complex.

For a discussion on the data types supported by Simulink, refer to Data Types Supported by Simulink in the Using Simulink documentation.

Parameters and Dialog Box

The Main pane of the Gain block dialog appears as follows:

Gain
Specify the value by which to multiply the input. The gain may be a scalar, vector, or matrix. The gain may not be Boolean.
Multiplication
Specify the multiplication mode:
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the online documentation for more information.

The Signal data types pane of the Gain block dialog appears as follows:

Output data type mode
Set the data type and scaling of the output to be the same as that of the input, or to be inherited via an internal rule or by back propagation. Alternatively, choose to specify the data type and scaling of the output through the Output data type and Output scaling value parameters in the dialog.
If you select Inherit via internal rule for this parameter, Simulink chooses a combination of output scaling and data type that requires the smallest amount of memory consistent with accommodating the output range and maintaining the output precision of the block and with the word size of the targeted hardware implementation specified for the model. If the Device type parameter on the Hardware implementation configuration parameters pane is set to ASIC/FPGA, Simulink chooses the output data type without regard to hardware constraints. Otherwise, Simulink chooses the smallest available hardware data type capable of meeting the range and precision constraints. For example, if the block multiplies an input of type int8 by a gain of int16 and ASIC/FPGA is specified as the targeted hardware type, the output data type is sfix24. If Unspecified (assume 32-bit Generic), i.e., a generic 32-bit microprocessor, is specified as the target hardware, the output data type is int32. If none of the word lengths provided by the target microprocessor can accommodate the output range, Simulink displays an error message in the Simulation Diagnostics Viewer.
Output data type
Set the output data type. This parameter is only visible if you select Specify via dialog for the Output data type mode parameter.
Output scaling value
Set the output scaling using either binary point-only or [Slope Bias] scaling. This parameter is only visible if you select Specify via dialog for the Output data type mode parameter.
Lock output scaling against changes by the autoscaling tool
Select to lock scaling of outputs. This parameter is only visible if you select Specify via dialog for the Output data type mode parameter.
Round integer calculations toward
Select the rounding mode for fixed-point operations.
Saturate on integer overflow
Select to have overflows saturate.

The Parameter data types pane of the Gain block dialog appears as follows:

Parameter data type mode
Set the data type and scaling of the gain to be the same as that of the input, or to be inherited via an internal rule. Alternatively, choose to specify the data type and scaling of the gain through the Parameter data type, Parameter scaling mode, and Parameter scaling parameters in the dialog.
Parameter data type
Specifies the data type of the Gain parameter. This parameter is visible only if you select Specify via dialog for the Parameter data type mode parameter.
Parameter scaling mode
Set the mode to determine the scaling of the gain.
Parameter scaling
Set the gain scaling using either binary point-only or [Slope Bias] scaling. This parameter is only visible if you select Specify via dialog for the Parameter data type mode parameter, and if you select Use specified scaling for the Parameter scaling mode parameter.

Characteristics

Direct Feedthrough
Yes
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes, of input and Gain parameter for Element-wise multiplication
Dimensionalized
Yes
Zero Crossing
No


Previous page  Function-Call Subsystem Goto Next page

© 1994-2005 The MathWorks, Inc.