Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Product - Multiply and divide scalars and nonscalars or multiply and invert matrices

Library

Math Operations

Description

Default Product Block Use

By default, the Product block outputs the result of multiplying two inputs: two scalars, a scalar and a nonscalar, or two nonscalars that have the same dimensions. The default parameter values that specify this behavior are:

Setting non-default values for either of these parameters can change a Product block to function as a Divide block or a Product of Elements block. See the documentation of those two blocks for more information.

If all you need is to multiply two inputs to create an output, you can use the Product block with default parameter values. If you need additional capabilities, see Product Block Capabilities.

The following table shows the output of the Product block for some typical inputs using default block parameter values.

Inputs and BehaviorExample

Scalar X Scalar

Output the product of the two inputs.

Scalar X Nonscalar

Output a nonscalar having the same dimensions as the input nonscalar. Each element of the output nonscalar is the product of the input scalar and the corresponding element of the input nonscalar.

Nonscalar X Nonscalar

Output a nonscalar having the same dimensions as the inputs. Each element of the output is the product of corresponding elements of the inputs.

Product Block Capabilities

The Product block, the Divide block, and the Product of Elements block are actually the same underlying block with different default values for the Number of inputs parameter. All three blocks can therefore provide the same capabilities. The Product block (or the Divide block or Product of Elements block if appropriately configured) can:

The Product block performs scalar or matrix multiplication, depending on the value of the Multiplication parameter. The block accepts one or more inputs, depending on the Number of inputs parameter. The Number of inputs parameter also specifies the operation to perform on each input.

The Product block can input any combination of scalars, vectors, and matrices for which the operation to perform has a mathematically defined result. The block performs the specified operations on the inputs, then outputs the result.

The Product block has two modes: Element-wise mode, which processes nonscalar inputs element by element, and Matrix mode, which processes nonscalar inputs as matrices. The next two sections describe these two modes.

Element-wise Mode

When the value of the Multiplication parameter is Element-wise(.*), the Product block is in Element-wise mode, in which it operates on the individual numeric elements of any nonscalar inputs. The MATLAB equivalent is the .* operator. In element-wise mode, the Product block can perform a variety of multiplication, division, and arithmetic inversion operations.

The value of the Number of inputs parameter controls both how many inputs exist and whether each is multiplied or divided to form the output. When the Product block in Element-wise mode has only one input, it is functionally equivalent to a Product of Elements block. When the block has multiple inputs, any nonscalar inputs must have identical dimensions, and the block outputs a nonscalar with those dimensions. To calculate the output, the block first expands any scalar input to a nonscalar that has the same dimensions as the nonscalar inputs.

This table shows the output of the Product block for some typical inputs, using the indicated values for the Number of inputs parameter.

Parameter ValuesExamples

Number of inputs: 2

Number of inputs: */

Number of inputs: /**/

Number of inputs: **

Number of inputs: */*

Matrix Mode

When the value of the Multiplication parameter is Matrix(*), the Product block is in Matrix mode, in which it processes nonscalar inputs as matrices. The MATLAB equivalent is the * operator. In Matrix mode, the Product block can invert a single square matrix, or multiply and divide any number of matrices that have dimensions for which the result is mathematically defined.

The value of the Number of inputs parameter controls both how many inputs exist and whether each input matrix is multiplied or divided to form the output. The syntax of Number of inputs is the same as in Element-wise mode. The difference between the modes is in the type of multiplication and division that occur.

Data Type Support

The Product block accepts real or complex signals of any numeric data type supported by Simulink software including fixed-point data types. For a discussion of the data types supported by Simulink software, see Data Types Supported by Simulink.

The Product block does not support numeric division for complex signals with boolean or fixed-point data types. For other types, the block accepts complex signals as divisors only when the input and output signals all specify the same built-in data type. In this case, however, the block ignores its specified rounding mode.

The Product block accepts multidimensional signals when operating in Element-wise mode, but not when operating in Matrix mode. See Signal Dimensions, Element-wise Mode, and Matrix Mode for more information.

Parameters and Dialog Box

The Main pane of the Product block dialog box appears as follows:

Signal Attributes Pane

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

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.

Number of inputs

Control two properties of the Product block:

Settings

Default:2

Dependency

Setting Number of inputs to * and selecting Element-wise(.*) for Multiplication enable the following parameter:

Command-Line Information

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

Multiplication

Specify whether the Product block operates in Element-wise mode or Matrix mode.

Settings

Default: Element-wise(.*)

Element-wise(.*)

Operate in Element-wise mode.

Matrix(*)

Operate in Matrix mode.

Dependency

Selecting Element-wise(.*) and setting Number of inputs to * enable the following parameter:

Command-Line Information

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

Multiply over

Affect multiplication on matrix input.

Settings

Default: All dimensions

All dimensions

Output a scalar that is product of all elements of the matrix, or the product of their inverses, depending on the value of Number of inputs.

Specified dimension

Output a vector, the composition of which depends on the value of the Dimension parameter.

Dependencies

Command-Line Information

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

Dimension

Affect multiplication on matrix input.

Settings

Default: 1

Minimum: 1

Maximum: 2

1

Output a vector that contains an element for each column of the input matrix.

2

Output a vector that contains an element for each row of the input matrix.

Tips

Each element of the output vector contains the product of all elements in the corresponding column or row of the input matrix, or the product of the inverses of those elements, depending on the value of Number of inputs:

Dependency

Enable this parameter by selecting Specified dimension for Multiply over.

Command-Line Information

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

Sample time (-1 for inherited)

Enter the discrete interval between sample time hits or specify another appropriate sample time such as continuous or inherited.

Settings

Default: -1

By default, the block inherits its sample time based upon the context of the block within the model. To set a different sample time, enter a valid sample time based upon the table in Types of Sample Time.

See also How to Specify the Sample Time in the online documentation for more information.

Command-Line Information

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

Require all inputs to have the same data type

Require that all inputs have the same data type.

Settings

Default: Off

On

Require that all inputs have the same data type.

Off

Do not require that all inputs have the same data type.

Command-Line Information

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

Lock output data type setting against changes by the fixed-point tools

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor.

Settings

Default: Off

On

Locks the output data type setting for this block.

Off

Allows the Fixed-Point Tool and the Fixed-Point Advisor to change the output data type setting for this block.

Command-Line Information

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

See Also

For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink Fixed Point documentation.

Integer rounding mode

Select the rounding mode for fixed-point operations.

Settings

Default: Zero

Ceiling

Round both positive and negative numbers toward positive infinity.

Convergent

Round number to the nearest representable value. If a tie occurs, round to the nearest even stored value.

Floor

Round both positive and negative numbers toward negative infinity.

Nearest

Round number to the nearest representable value. If a tie occurs, round toward positive infinity.

Round

Round number to the nearest representable value. If a tie occurs, round positive numbers toward positive infinity and round negative numbers toward negative infinity.

Simplest

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

Zero

Round number toward zero.

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.

Tips

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), 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

Use data type of the driving block.

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 is the 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).

Enum: <class name>

Use an enumerated data type, for example, Enum: BasicColors. This option appears for some blocks.

<data type expression>

Use 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.

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. The following list is the possible values, which can vary by block:

  • Inherit from 'Constant value' (Constant block default)

  • Inherit via internal rule (Discrete-Time Integrator, Gain, Product, Sum, Switch block default)

  • Inherit via back propogation (Data Type Conversion block default)

  • auto (Inport, Outport block default)

  • Logical (see Configuration Parameters: Optimization)

  • Same as first input

  • Same as input (Saturation block default)

  • Same as accumulator

Built in

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

  • double (Constant, Data Type Conversion, Discrete-Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch block default)

  • single

  • int8

  • uint8

  • int16

  • uint16

  • int32

  • uint32

  • boolean (Logical Operator, Relational Operator block default)

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. The following list is the possible values, which can vary by block:

  • <class name>

Expression

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

  • <data type expression>

Dependency

Clicking the Show data type assistant button enables this parameter.

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.

Signedness

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

Settings

Default: Signed

Signed

Specify the fixed-point data as signed.

Unsigned

Specify the fixed-point data as unsigned.

Dependencies

Selecting Mode > Fixed point enables this parameter.

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 holds the quantized integer.

Settings

Default: 16

Minimum: 0

Maximum: 32

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

Dependencies

Selecting Mode > Fixed point enables this parameter.

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

Selecting Mode > Fixed point enables this parameter.

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

Selecting Scaling > Binary point enables this parameter.

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

Selecting Scaling > Slope and bias enables this parameter.

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

Selecting Scaling > Slope and bias enables this parameter.

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

Dimensionalized

Yes

Multidimensionalized

Yes, only when the Multiplication parameter specifies Element-wise(.*)

Zero Crossing

No

See Also

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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