| Simulink | ![]() |
www.kxcad.net Home > CAE Software Index > MATLAB Index >
Math Operations

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.
The Gain block accepts a real or complex scalar, vector, or matrix of any data type supported by Simulink. 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, see Data Types Supported by Simulink in the Simulink documentation.
The Main pane of the Gain block dialog appears as follows:

Specify the value by which to multiply the input. The gain may be a scalar, vector, or matrix. The gain may not be Boolean.
Specify the multiplication mode:
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 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 Attributes pane of the Gain block dialog appears as follows:

Specify the minimum value that the block should output. The default value, [], is equivalent to -Inf. Simulink uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via back propagation
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, float('single')
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output data type parameter.
See Specifying Block Output Data Types for more information.
If you select Inherit: 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.
Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.
Select the rounding mode for fixed-point operations.
Select to have overflows saturate.
The Parameter Attributes pane of the Gain block dialog appears as follows:

Specify the minimum value of the gain. The default value, [], is equivalent to -Inf. Simulink uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Automatic scaling of fixed-point data types
Specify the maximum value of the gain. The default value, [], is equivalent to Inf. Simulink uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Automatic scaling of fixed-point data types
Specify the data type of the Gain parameter. You can set it to:
A rule that inherits a data type, for example, Inherit: Same as input
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, float('single')
Click the Show
data type assistant button
to display the Data Type Assistant,
which helps you set the Parameter data type parameter.
(See Using the Data Type Assistant.)
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes, of input and Gain parameter for Element-wise(K.*u) multiplication |
Dimensionalized | Yes |
Multidimensionalized | Yes, only if the Multiplication parameter specifies Element-wise(K.*u) |
Zero Crossing | No |
| Function-Call Subsystem | Goto | ![]() |
© 1984-2007 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments