Gain - Multiply input by 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 numeric data type supported by Simulink software. 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 software, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

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

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

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

Gain

Specify the value by which to multiply the input.

Settings

Default: 1
Minimum: value of Parameter minimum parameter
Maximum: value of Parameter maximum parameter

The gain may be a scalar, vector, or matrix. The gain may not be Boolean.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Multiplication

Specify the multiplication mode.

Settings

Default: Element-wise(K.*u)

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.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Sample time (-1 for inherited)

Specify the time interval between samples.

Settings

Default: -1

To inherit the sample time, set this parameter to -1.

See Specifying Sample Time in the online documentation for more information.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output minimum

Specify the minimum value that the block should output.

Settings

Default: []

The default value, [], is equivalent to -Inf.

Simulink software uses this value to perform:

Tip

This number must be a double scalar value.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output maximum

Specify the maximum value that the block should output.

Settings

Default: []

The default value, [], is equivalent to Inf.

Simulink software uses this value to perform:

Tip

This number must be a double scalar value.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output data type

Specify the output data type.

Settings

Default: Inherit: Inherit via internal rule (Discrete-Time Integrator, Gain, Product, Sum, Switch block), Inherit: Inherit from 'Constant value' (Constant block default), Inherit: Inherit via back propagation (Data Type Conversion block), Inherit: Same as input (Saturation block)

Inherit: Inherit via internal rule

This option appears for some blocks. Simulink software chooses a combination of output scaling and data type that requires the smallest amount of memory consistent with accommodating the calculated 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 software chooses the output data type without regard to hardware constraints. Otherwise, Simulink software 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 software displays an error message in the Simulation Diagnostics Viewer.

Inherit: Inherit from 'Constant value'

Use data type of Constant value parameter. This option appears for some blocks.

Inherit: Inherit via back propagation

A rule that inherits a data type

Inherit: Same as input

Use data type of sole input signal. This option appears for some blocks.

Inherit: Same as first input

Use data type of first input signal. This option appears for some blocks.

Inherit: Same as accumulator

Output data type same as accumulator data type. This option appears for some blocks.

double

Output data type is double.

single

Output data type is single.

int8

Output data type is int8.

uint8

Output data type is uint8.

int16

Output data type is int16.

uint16

Output data type is uint16.

int32

Output data type is int32.

uint32

Output data type is unt32.

fixdt(1,16,0)

Output data type is fixed point fixdt(1,16,0).

fixdt(1,16,2^0,0)

Output data type is fixed point fixdt(1,16,2^0,0).

<data type expression>

The name of a data type object, for example Simulink.NumericType

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying Block Output Data Types in the Simulink User's Guide for more information.

Show data type assistant

Display the Data Type Assistant.

Settings

The Data Type Assistant helps you set the Output data type parameter.

See Specifying Block Output Data Types for more information.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Lock output scaling against changes by the autoscaling tool

Select to lock scaling of outputs.

Settings

Default: Off

On

Lock scaling of outputs.

Off

Do not lock scaling of outputs.

Dependencies

This parameter is enabled when you enter an expression for the Output data type or Data type parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Round integer calculations toward

Select the rounding mode for fixed-point operations.

Settings

Default: Floor

Zero

Round number toward zero.

Nearest

Round number to the nearest representable value.

Ceiling

Round both positive and negative numbers toward positive infinity.

Floor

Round both positive and negative numbers toward negative infinity.

Simplest

This option provides for an optimization of the rounding code for several blocks.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

For more information, see Rounding in the Simulink Fixed Point User's Guide.

Saturate on integer overflow

Specify whether overflows saturate.

Settings

Default: Off

On

Overflows saturate.

Off

Overflows do not saturate.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Parameter minimum

Specify the minimum value of the gain.

Settings

Default: []

The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:

Command-Line Information

See Block-Specific Parameters for the command-line information.

Parameter maximum

Specify the maximum value of the gain.

Settings

Default: []

The default value, [], is equivalent to Inf. Simulink software uses this value to perform:

Command-Line Information

See Block-Specific Parameters for the command-line information.

Parameter data type

Specify the data type of the Gain parameter.

Settings

Default:

Inherit: Inherit via internal rule

A rule that inherits a data type

Inherit: Same as input

Use data type of sole input signal

double

Data type is double

single

Data type is single

int8

Data type is int8

uint8

Data type is uint8

int16

Data type is int16

uint16

Data type is uint16

int32

Data type is int32

uint32

Data type is uint32

fixdt(1,16)

Data type is fixdt(1,16)

fixdt(1,16,0)

Data type is fixdt(1,16,0)

fixdt(1,16,2^0,0)

Data type is fixdt(1,16,2^0,0)

<data type expression>

The name of a data type object, for example Simulink.NumericType

Command-Line Information

See Block-Specific Parameters for the command-line information.

Mode

Select the category of data to specify

Settings

Default: Inherit (Constant, Data Type Conversion, Discrete Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch), Built in (Logical Operator, Relational Operator)

Inherit

Inheritance rules for data types. Selecting Inherit enables a second menu/text box to the right. Below are the possible values, which can vary by block:

Built in

Built-in data types. Selecting Built in enables a second menu/text box to the right. Below are the possible values, which can vary by block:

Fixed point

Fixed-point data types.

Enumerated

Enumerated data types. This option is available on some blocks. Selecting Enumerated enables a second menu/text box to the right. Below are the possible values, which can vary by block:

Expression

Expressions that evaluate to data types. Selecting Expression enables a second menu/text box to the right. Below are the possible values, which can vary by block:

Dependency

This parameter is enabled by the Show data type assistant button.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Using the Data Type Assistant in the Simulink User's Guide.

Sign

Specify whether you want the fixed-point data to be signed or unsigned.

Settings

Default: Signed

Signed

Specify the fixed-point data to be signed.

Unsigned

Specify the fixed-point data to be unsigned.

Dependencies

This parameter is enabled by selecting Mode > Fixed point.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Word length

Specify the bit size of the word that will hold the quantized integer.

Settings

Default: 16

Minimum: 0

Maximum: 32

Large word sizes represent large values with greater precision than small word sizes.

Dependencies

This parameter is enabled by selecting Mode > Fixed point.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Scaling

Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors.

Settings

Default: Best precision (Constant), Binary point (Data Type Conversion, Discrete-Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch), Integer (Logical Operator, Relational Operator)

Binary point

Specify binary point location.

Slope and bias

Enter slope and bias.

Best precision

Specify best-precision values. This option appears for some blocks.

Integer

Specify integer. This setting has the same result as specifying a binary point location and setting fraction length to 0. This option appears for some blocks.

Dependencies

This parameter is enabled by selecting Mode > Fixed point.

Selecting Binary point enables

Selecting Slope and bias enables:

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Fraction length

Specify fraction length for fixed-point data type.

Settings

Default: 0

Binary points can be positive or negative integers.

Dependencies

This parameter is enabled by selecting Scaling > Binary point.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Slope

Specify slope for the fixed-point data type.

Settings

Default: 2^0

Specify any positive real number.

Dependencies

This parameter is enabled by selecting Scaling > Slope and bias.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Bias

Specify bias for the fixed-point data type.

Settings

Default: 0

Specify any real number.

Dependencies

This parameter is enabled by selecting Scaling > Slope and bias.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Characteristics

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

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS