Multiply and divide scalars and nonscalars or multiply and invert matrices
Math Operations
The Divide and Product of Elements blocks are variants of the Product block.
For information on the Divide block, see Divide.
For information on the Product of Elements block, see Product of Elements.
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:
Multiplication: Elementwise(.*)
Number of inputs: 2
The following table shows the output of the Product block for example inputs using default block parameter values.
Inputs and Behavior  Example 

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. 

The Product block (or the Divide block or Product of Elements block, if appropriately configured) can:
Numerically multiply and divide any number of scalar, vector, or matrix inputs
Perform matrix multiplication and division on any number of matrix inputs
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: Elementwise 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.
When the value of the Multiplication parameter
is Elementwise(.*)
, the Product block
is in Elementwise mode, in which it operates
on the individual numeric elements of any nonscalar inputs. The MATLAB^{®} equivalent
is the .*
operator. In elementwise 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 Elementwise 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 example inputs, using the indicated values for the Number of inputs parameter.
Parameter Values  Examples 

Number of inputs: 

Number of inputs: 

Number of inputs: 

Number of inputs: 

Number of inputs: 

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 Elementwise mode. The difference between the modes is in the type of multiplication and division that occur.
For elementwise operations on complex floatingpoint inputs, simulation and code generation results might differ in nearoverflow cases. Although complex numbers is selected and nonfinite numbers is not selected on the Code Generation > Interface pane of the Configuration Parameters dialog box, the code generator does not emit special case code for intermediate overflows. This method improves the efficiency of embedded operations for the general case that does not include extreme values. If the inputs might include extreme values, please manage these cases explicitly.
The generated code might not produce the exact same pattern
of NaN
and inf
values as simulation
when these values are mathematically meaningless. For example, if
the simulation output contains a NaN
, output from
the generated code also contains a NaN
, but not
necessarily in the same place.
The Product block accepts real or complex signals of any numeric data type that Simulink^{®} supports, including fixedpoint data types. For more information, see Data Types Supported by Simulink in the Simulink documentation.
The Product block does not support numeric division for complex
signals with boolean
or fixedpoint data types.
For other types, the block accepts complex signals as divisors only
when the input and output signals all specify the same builtin data
type. In this case, however, the block ignores its specified rounding
mode.
The Product block accepts multidimensional signals when operating in Elementwise mode, but not when operating in Matrix mode. See Signal Dimensions, Elementwise Mode, and Matrix Mode for more information.
Control two properties of the block:
The number of input ports on the block
Whether each input is multiplied or divided into the output
Default: 2
for
Product block, */
for Divide block,
and *
for Product of
Elements block
1
or *
or /
Has one input. In elementwise mode, processes the input as
described for the Product of Elements block.
In matrix mode, if the parameter value is 1
or *
,
the block outputs the input value. If the value is /
,
the input must be a square matrix (including a scalar as a degenerate
case) and the block outputs the matrix inverse. See Elementwise Mode and Matrix Mode for more information.
Integer value > 1
Has the number of inputs given by the integer value. The inputs are multiplied together in elementwise mode or matrix mode, as specified by the Multiplication parameter. See Elementwise Mode and Matrix Mode for more information.
Unquoted string of two or more *
and /
characters
Has the number of inputs given by the length of the string.
Each input that corresponds to a *
character is
multiplied into the output. Each input that corresponds to a /
character
is divided into the output. The operations occur in elementwise mode
or matrix mode, as specified by the Multiplication parameter.
See Elementwise Mode and Matrix Mode for more information.
Setting Number of inputs to *
and
selecting Elementwise(.*)
for Multiplication enables
the Multiply over parameter.
See BlockSpecific Parameters for the commandline information.
Specify whether the Product block operates in Elementwise mode or Matrix mode.
Default: Elementwise(.*)
Elementwise(.*)
Operate in Elementwise mode.
Matrix(*)
Operate in Matrix mode.
Selecting Elementwise(.*)
and setting Number
of inputs to *
enable the following
parameter:
Multiply over
See BlockSpecific Parameters for the commandline information.
Affect multiplication on matrix input.
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.
Enable this parameter by selecting Elementwise(.*)
for Multiplication and
setting Number of inputs to *
or 1
or /
.
Setting this parameter to Specified dimension
enables
the Dimension parameter.
See BlockSpecific Parameters for the commandline information.
Affect multiplication on matrix input.
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.
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:
1
or *
Multiply the values of the column or row elements
/
Multiply the inverses of the column or row elements
Enable this parameter by selecting Specified dimension
for Multiply
over.
See BlockSpecific Parameters for the commandline information.
Note:
This parameter is not visible in the block dialog box unless
it is explicitly set to a value other than 
Require that all inputs have the same data type.
Default: Off
Require that all inputs have the same data type.
Do not require that all inputs have the same data type.
See BlockSpecific Parameters for the commandline information.
Lower value of the output range that Simulink checks.
Default: []
(unspecified)
Specify this number as a finite, real, double, scalar value.
Simulink uses the minimum to perform:
Parameter range checking (see Control Block Parameter Value Ranges) for some blocks
Simulation range checking (see Signal Ranges and Enabling Simulation Range Checking)
Automatic scaling of fixedpoint data types
Note: Output minimum does not saturate or clip the actual output signal. Use the Saturation block instead. 
Parameter: OutMin 
Type: string 
Value: '[ ]' 
Default: '[ ]' 
Upper value of the output range that Simulink checks.
Default: []
(unspecified)
Specify this number as a finite, real, double, scalar value.
Simulink uses the maximum value to perform:
Parameter range checking (see Control Block Parameter Value Ranges) for some blocks
Simulation range checking (see Signal Ranges and Enabling Simulation Range Checking)
Automatic scaling of fixedpoint data types
Note: Output maximum does not saturate or clip the actual output signal. Use the Saturation block instead. 
Parameter: OutMax 
Type: string 
Value: '[ ]' 
Default: '[ ]' 
Specify the output data type.
Default: Inherit:
Inherit via internal rule
Inherit: Inherit via internal rule
Simulink chooses a data type to balance numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware. If you change the embedded target settings, the data type selected by the internal rule might change. It is not always possible for the software to optimize code efficiency and numerical accuracy at the same time. If the internal rule doesn't meet your specific needs for numerical accuracy or performance, use one of the following options:
Specify the output data type explicitly.
Use the simple choice of Inherit: Same
as first input
.
Explicitly specify a default data type such as fixdt(1,32,16)
and
then use the FixedPoint Tool to propose data types for your model.
For more information, see fxptdlg
.
To specify your own inheritance rule, use Inherit:
Inherit via back propagation
and then use a Data Type Propagation block. Examples
of how to use this block are available in the Signal Attributes library Data
Type Propagation Examples block.
Inherit: Inherit via back propagation
Use data type of the driving block.
Inherit: Same as first input
Use data type of the first input signal.
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 uint32
.
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>
Use a data type object, for example, Simulink.NumericType
.
See BlockSpecific Parameters for the commandline information.
For more information, see Control Signal Data Types.
Display the Data Type Assistant.
The Data Type Assistant helps you set the Output data type parameter.
For more information, see Control Signal Data Types.
Select the category of data to specify.
Default: Inherit
Inherit
Inheritance rules for data types. Selecting Inherit
enables
a second menu/text box to the right. Select one of the following choices:
Inherit via internal rule
(default)
Inherit via back propagation
Same as first input
Built in
Builtin data types. Selecting Built in
enables
a second menu/text box to the right. Select one of the following choices:
double
(default)
single
int8
uint8
int16
uint16
int32
uint32
Fixed point
Fixedpoint data types.
Expression
Expressions that evaluate to data types. Selecting Expression
enables
a second menu/text box to the right, where you can enter the expression.
Clicking the Show data type assistant button enables this parameter.
See BlockSpecific Parameters for the commandline information.
See Specify Data Types Using Data Type Assistant.
Specify data type override mode for this signal.
Default: Inherit
Inherit
Inherits the data type override setting from its context, that
is, from the block, Simulink.Signal
object or Stateflow^{®} chart
in Simulink that is using the signal.
Off
Ignores the data type override setting of its context and uses the fixedpoint data type specified for the signal.
The ability to turn off data type override for an individual data type provides greater control over the data types in your model when you apply data type override. For example, you can use this option to ensure that data types meet the requirements of downstream blocks regardless of the data type override setting.
This parameter appears only when the Mode is Built
in
or Fixed point
.
Specify whether you want the fixedpoint data as signed or unsigned.
Default: Signed
Signed
Specify the fixedpoint data as signed.
Unsigned
Specify the fixedpoint data as unsigned.
Selecting Mode > Fixed
point
enables this parameter.
For more information, see Specifying a FixedPoint Data Type.
Specify the bit size of the word that holds the quantized integer.
Default: 16
Minimum: 0
Maximum: 32
Selecting Mode > Fixed
point
enables this parameter.
For more information, see Specifying a FixedPoint Data Type.
Specify the method for scaling your fixedpoint data to avoid overflow conditions and minimize quantization errors.
Default: Best
precision
Binary point
Specify binary point location.
Slope and bias
Enter slope and bias.
Best precision
Specify bestprecision values.
Selecting Mode > Fixed
point
enables this parameter.
Selecting Binary point
enables:
Fraction length
Calculate BestPrecision Scaling
Selecting Slope and bias
enables:
Slope
Bias
Calculate BestPrecision Scaling
For more information, see Specifying a FixedPoint Data Type.
Specify fraction length for fixedpoint data type.
Default: 0
Binary points can be positive or negative integers.
Selecting Scaling > Binary
point
enables this parameter.
For more information, see Specifying a FixedPoint Data Type.
Specify slope for the fixedpoint data type.
Default: 2^0
Specify any positive real number.
Selecting Scaling > Slope
and bias
enables this parameter.
For more information, see Specifying a FixedPoint Data Type.
Specify bias for the fixedpoint data type.
Default: 0
Specify any real number.
Selecting Scaling > Slope
and bias
enables this parameter.
For more information, see Specifying a FixedPoint Data Type.
Select to lock the output data type setting of this block against changes by the FixedPoint Tool and the FixedPoint Advisor.
Default: Off
Locks the output data type setting for this block.
Allows the FixedPoint Tool and the FixedPoint Advisor to change the output data type setting for this block.
Parameter: LockScale 
Type: string 
Value: 'off'  'on' 
Default: 'off' 
For more information, see Use Lock Output Data Type Setting.
Specify the rounding mode for fixedpoint operations.
Default: Floor
Ceiling
Rounds positive and negative numbers toward positive infinity.
Equivalent to the MATLAB ceil
function.
Convergent
Rounds number to the nearest representable value. If a tie occurs,
rounds to the nearest even integer. Equivalent to the FixedPoint Designer™ convergent
function.
Floor
Rounds positive and negative numbers toward negative infinity.
Equivalent to the MATLAB floor
function.
Nearest
Rounds number to the nearest representable value. If a tie occurs,
rounds toward positive infinity. Equivalent to the FixedPoint Designer nearest
function.
Round
Rounds number to the nearest representable value. If a tie occurs,
rounds positive numbers toward positive infinity and rounds negative
numbers toward negative infinity. Equivalent to the FixedPoint Designer round
function.
Simplest
Chooses between rounding toward floor and rounding toward zero to generate rounding code that is as efficient as possible.
Zero
Rounds number toward zero. Equivalent to the MATLAB fix
function.
See BlockSpecific Parameters for the commandline information.
For more information, see Rounding.
Specify whether overflows saturate.
Default: Off
Overflows saturate to either the minimum or maximum value that the data type can represent.
For example, an overflow associated with a signed 8bit integer can saturate to 128 or 127.
Overflows wrap to the appropriate value that the data type can represent.
For example, the number 130 does not fit in a signed 8bit integer and wraps to 126.
Consider selecting this check box when your model has a possible overflow and you want explicit saturation protection in the generated code.
Consider clearing this check box when you want to optimize efficiency of your generated code.
Clearing this check box also helps you to avoid overspecifying how a block handles outofrange signals. For more information, see Checking for Signal Range Errors.
When you select this check box, saturation applies to every internal operation on the block, not just the output or result.
In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.
Parameter: SaturateOnIntegerOverflow 
Type: string 
Value: 'off'  'on' 
Default: 'off' 
Data Types  Double  Single  Boolean  Base Integer  FixedPoint 
Sample Time  Inherited from driving block 
Direct Feedthrough  Yes 
Multidimensional Signals  Yes 
VariableSize Signals  Yes 
ZeroCrossing Detection  No 
Code Generation  Yes 