Simulink Reference | ![]() ![]() |
Multiply the input by a constant
Library
Simulink Math Operations and Fixed-Point Blockset Math
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.
When the Show additional parameters check box is selected, some of the parameters that become visible are common to many blocks. For a detailed description of these parameters, refer to Block Parameters in the Fixed-Point Blockset documentation.
The Matrix gain block is an implementation of the Gain block with different default settings.
Data Type Support
The input and gain of the Gain block can be a real or complex scalar, vector, or matrix of any data type except boolean
, int64,
and uint64
. If the input is real and the gain is complex, the output is complex.
Parameters and Dialog Box
Element-wise(K*u)
--Each element of the input is multiplied by each element of the gain. The block performs expansions, if necessary, so that the input and gain have the same dimensions.
Matrix(K*u)
--The input and gain are matrix multiplied with the input as the second operand.
Matrix(u*K)
--The input and gain are matrix multiplied with the input as the first operand.
Matrix(K*u)(u vector)
--The input and gain are matrix multiplied with the input as the second operand. The input and the output are required to be vectors and their lengths are determined by the dimensions of the gain.
Specify via dialog
is selected for the Parameter data type mode parameter.Use specified scaling
--This mode allows you to set the scaling of the gain in the Parameter scaling parameter.
Best Precision: Element-wise
--This mode sets radix points for the elements of the gain such that the precision of each element is maximized.
Best Precision: Row-wise
--This mode sets a common radix point within each row of the gain such that the largest element of each row has the best possible precision.
Best Precision: Column-wise
--This mode sets a common radix point within each column of the gain such that the largest element of each column has the best possible precision.
Best Precision: Matrix-wise
--This mode sets a common radix point for all the elements of the gain such that the largest element has the best possible precision.
Specify via dialog
is selected for the Parameter data type mode parameter.Specify via dialog
is selected for the Parameter data type mode parameter, and if Use specified scaling
is selected for the Parameter scaling mode parameter.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. If the Production hardware characteristics parameter on the Advanced pane of the Simulation Parameters dialog is set to Unconstrained integer sizes
, Simulink chooses the output data type without regard to hardware constraints. If the parameter is set to Microprocessor
, 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 Unconstrained integer sizes
is specified, the output data type is sfix24
. If Microprocessor
is specified and the microprocessor supports 8-bit, 16-bit, and 32-bit words, 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 Simulink Diagnostic Viewer.Specify via dialog
is selected for the Output data type mode parameter.Specify via dialog
is selected for the Output data type mode parameter.Specify via dialog
is selected for the Output data type mode parameter.Conversions and Operations
The gain is converted from doubles to the specified data type offline using round-to-nearest and saturation. Refer to Parameter Conversions in the Fixed-Point Blockset documentation for more information about parameter conversions. The input and gain are then multiplied, and the result is converted to the output data type using the specified rounding and overflow modes. Refer to Rules for Arithmetic Operations in the Fixed-Point Blockset documentation for more information about the rules that this block obeys when performing fixed-point operations.
Characteristics
Dimensionalized |
Yes |
Direct Feedthrough |
Yes |
Sample Time |
Inherited from driving block |
Scalar Expansion |
Of input and Gain parameter for Element-wise multiplication |
Zero Crossing |
No |
![]() | Function-Call Subsystem | Goto | ![]() |