Documentation

Matrix Product

Multiply matrix elements along rows, columns, or entire input

Library

Math Functions / Matrices and Linear Algebra / Matrix Operations

dspmtrx3

Description

The Matrix Product block multiplies the elements of an M-by-N input matrix u along its rows, its columns, or over all its elements.

When the Multiply over parameter is set to Rows, the block multiplies across the elements of each row and outputs the resulting M-by-1 matrix. The block treats length-N unoriented vector input as a 1-by-N matrix.

[u11u12u13u21u22u23u31u32u33][y1y2y3]=[(j=13u1j)(j=13u2j)(j=13u3j)]

When the Multiply over parameter is set to Columns, the block multiplies down the elements of each column and outputs the resulting 1-by-N matrix. The block treats length-M unoriented vector input as an M-by-1 matrix.

[u11u12u13u21u22u23u31u32u33][y1y2y3]=[(i=13ui1)(i=13ui2)(i=13ui3)]

When the Multiply over parameter is set to Entire input, the block multiplies all the elements of the input together and outputs the resulting scalar.

[u11u12u13u21u22u23u31u32u33]y=(i=13j=13uij)

Fixed-Point Data Types

The following diagram shows the data types used within the Matrix Product block for fixed-point signals.

The output of the multiplier is in the product output data type when at least one of the inputs to the multiplier is real. When both of the inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed, see Multiplication Data Types. You can set the accumulator, product output, intermediate product, and output data types in the block dialog as discussed in Dialog Box below.

Dialog Box

The Main pane of the Matrix Product block dialog appears as follows.

Multiply over

Indicate whether to multiply together the elements of each row, each column, or the entire input.

The Data Types pane of the Matrix Product block dialog appears as follows.

    Note:   Floating-point inheritance takes precedence over the data type settings defined on this pane. When inputs are floating point, the block ignores these settings, and all internal data types are floating point.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Intermediate product

Specify the intermediate product data type. As shown in Fixed-Point Data Types, the output of the multiplier is cast to the intermediate product data type before the next element of the input is multiplied into it. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same as input

  • An expression that evaluates to a valid data type, for example, fixdt([],16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Product output data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Product output data type

Specify the product output data type. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Inherit via internal rule

  • An expression that evaluates to a valid data type, for example, fixdt([],16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Product output data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Accumulator data type

Specify the accumulator data type. See Fixed-Point Data Types for illustrations depicting the use of the accumulator data type in this block. You can set this parameter to:

  • A rule that inherits a data type, for example, Inherit: Inherit via internal rule

  • An expression that evaluates to a valid data type, for example, fixdt([],16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Accumulator data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Output data type

Specify the output data type. See Fixed-Point Data Types for illustrations depicting the use of the output data type in this block. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same as product output

  • An expression that evaluates to a valid data type, for example, fixdt([],16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.

See Specify Block Output Data Types for more information.

Minimum

Specify the minimum value that the block should output. The default value is [] (unspecified). Simulink® software uses this value to perform:

  • Simulation range checking (see Signal Ranges)

  • Automatic scaling of fixed-point data types

Maximum

Specify the maximum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:

  • Simulation range checking (see Signal Ranges)

  • Automatic scaling of fixed-point data types

Lock data type settings against changes by the fixed-point tools

Select this parameter to prevent the fixed-point tools from overriding the data types you specify on the block mask.

Supported Data Types

Port

Supported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Output

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

See Also

Array-Vector MultiplyDSP System Toolbox
Matrix SquareDSP System Toolbox
Matrix SumDSP System Toolbox
prodMATLAB

Was this topic helpful?