| Signal Processing Blockset™ | ![]() |
Compute cumulative product of channel, column, or row elements
Math Functions / Math Operations
dspmathops

The Cumulative Product block computes the cumulative product of elements in each channel, column, or row of the M-by-N input matrix.
The inputs can be sample-based or frame-based vectors and matrices. The output always has the same dimensions, rate, frame status, data type, and complexity as the input.
The Cumulative Product block accepts real and complex fixed-point and floating-point inputs except for complex unsigned fixed-point inputs.
The block computes the cumulative product of both sample- and frame-based vector and matrix inputs. Inputs can be real or complex. When multiplying along channels or columns, 1-D unoriented vectors are treated as column vectors. When multiplying along rows, 1-D vectors are treated as row vectors.
The optional reset port, Rst, accepts scalar values, which can be any built-in Simulink® data type including boolean. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input.
The output always has the same dimensions, rate, frame status, data type, and complexity as the data signal input.
For frame-based inputs, the block treats each input column as an independent channel. As the following figure and equation illustrate, the output has the following characteristics:
The first row of the first output is the same as the first row of the first input.
The first row of each subsequent output is the element-wise product of the first row of the current input (time t), and the last row of the previous output (time t - Tf, where Tf is the frame period).
The output has the same size, dimension, frame status, data type, and complexity as the input.
Given an M-by-N frame-based input, u, the output, y, is a frame-based M-by-N matrix whose first row has elements
![]()

For sample-based inputs, the block treats each element of the input matrix as an independent channel. As the following figure and equation illustrate, the output has the following characteristics:
The first output is the same as the first input.
Each subsequent output is the element-wise product of the current input (time t) and the previous output (time t - Ts, where Ts is the sample period).
The output has the same size, dimension, frame status, data type, and complexity as the input.
Given an M-by-N sample-based input, u, the output, y, is a sample-based M-by-N matrix with the elements
![]()
For convenience, length-M 1-D vector inputs are treated as M-by-1 column vectors when multiplying along channels, and the output is a length-M 1-D vector.

When you set the Multiply input along parameter to Channels (running product), you can set the block to reset the running product whenever it detects a reset event at the optional Rst port. The reset sample time must be a positive integer multiple of the input sample time. The input to the Rst port can be of the Boolean data type.
When the block is reset for sample-based inputs, the block initializes the current output to the values of the current input. For frame-based inputs, the block initializes the first row of the current output to the values in the first row of the current input.
The Reset port parameter specifies the reset event, which can be one of the following:
None disables the Rst port.
Rising edge — Triggers a reset operation when the Rst input does one of the following:
Rises from a negative value to a positive value or zero
Rises from zero to a positive value, where the rise is not a continuation of a rise from a negative value to zero (see the following figure)

Falling edge — Triggers a reset operation when the Rst input does one of the following:
Falls from a positive value to a negative value or zero
Falls from zero to a negative value, where the fall is not a continuation of a fall from a positive value to zero (see the following figure)

Either edge — Triggers a reset operation when the Rst input is a Rising edge or Falling edge (as described above)
Non-zero sample — Triggers a reset operation at each sample time that the Rst input is not zero
Note When running simulations in the Simulink MultiTasking mode, reset signals have a one-sample latency. Therefore, when the block detects a reset event, there is a one-sample delay at the reset port rate before the block applies the reset. For more information on latency and the Simulink tasking modes, see Excess Algorithmic Delay (Tasking Latency) and Models with Multiple Sample Rates in the Real-Time Workshop® User's Guide. |
When the Multiply input along parameter is set to Columns, the block computes the cumulative product of each column of the input, where the current cumulative product is independent of the cumulative products of previous inputs.
y = cumprod(u) % Equivalent MATLAB code
The output has the same size, dimension, frame status, data type, and complexity as the input. The mth output row is the element-wise product of the first m input rows.
Given an M-by-N input, u, the output, y, is an M-by-N matrix whose jth column has elements

The block treats length-M 1-D vector inputs as M-by-1 column vectors when multiplying along columns.

When the Multiply input along parameter is set to Rows, the block computes the cumulative product of the row elements, where the current cumulative product is independent of the cumulative products of previous inputs.
y = cumprod(u,2) % Equivalent MATLAB code
The output has the same size, dimension, frame status, and data type as the input. The nth output column is the element-wise product of the first n input columns.
Given an M-by-N input, u, the output, y, is an M-by-N matrix whose ith row has elements

The block treats length-N 1-D vector inputs as 1-by-N row vectors when multiplying along rows.

The following diagram shows the data types used within the Cumulative 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.
The Main pane of the Cumulative Product block dialog appears as follows.

The dimension along which to compute the cumulative products. The options allow you to multiply along Channels (running product), Columns, and Rows. For more information, see the following sections:
Determines the reset event that causes the block to reset the product along channels. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input. This parameter is enabled only when you set the Multiply input along parameter to Channels (running product). For more information, see Resetting the Cumulative Product Along Channels.
The Fixed-point pane of the Cumulative Product block dialog appears as follows.

Select the rounding mode for fixed-point operations.
Select the overflow mode for fixed-point operations.
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. Use this parameter to specify how you would like to designate the intermediate product word and fraction lengths:
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the intermediate product, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the intermediate product. This block requires power-of-two slope and a bias of zero.
Use this parameter to specify how you would like to designate the product output word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block:
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. This block requires power-of-two slope and a bias of zero.
Use this parameter to specify how you would like to designate the accumulator word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the accumulator data type in this block. Note that the accumulator data type is only used when both inputs to the multiplier are complex:
When you select Same as product output, these characteristics match those of the product output.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. This block requires power-of-two slope and a bias of zero.
Choose how you specify the word length and fraction length of the output of the block:
When you select Same as product output, these characteristics match those of the product output.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the output, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the output. This block requires power-of-two slope and a bias of zero.
Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool.
| Input and Output Ports | Supported Data Types |
|---|---|
Data input port, In |
|
Reset input port, Rst | All built-in Simulink data types:
|
Output port |
|
| Cumulative Sum | Signal Processing Blockset |
| Matrix Product | Signal Processing Blockset |
| cumprod | MATLAB |
![]() | Create Diagonal Matrix | Cumulative Sum | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |