DSP Blockset    
Cumulative Sum

Compute the cumulative sum of channel, column, or row elements

Library

Math Functions / Math Operations

Description

The Cumulative Sum block computes the cumulative sum of the 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 size, dimension, rate, frame status, data type, and complexity as the input.

Sections of This Reference Page

Input and Output Characteristics

Valid Input to Sum.   The block computes the cumulative sum of both sample- and frame-based vector and matrix inputs. Inputs can be real or complex. When summing along channels or columns, 1-D unoriented vectors are treated as column vectors. When summing along rows, 1-D vectors are treated as row vectors.

Valid Reset Signal.   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.

Output Characteristics.   The output always has the same size, dimension, rate, frame status, data type, and complexity as the data signal input.

Summing Along Channels

When the Sum input along parameter is set to Channels (running sum), the block computes the cumulative sum of the elements in each input channel. The running sum of the current input takes into account the running sum of all previous inputs. See the following sections for more information:

Summing Along Channels of Frame-Based Inputs.   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:

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

Summing Along Channels of Sample-Based Inputs.   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:

Given an M-by-N sample-based input, u, the output, y, is a sample-based M-by-N matrix with the elements

Resetting the Cumulative Sum Along Channels.   When you set the Sum input along parameter to Channels (running sum), you can set the block to reset the running sum whenever it detects a reset event at the optional Rst port. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input. 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:

Summing Along Columns

When the Sum input along parameter is set to Columns, the block computes the cumulative sum of each column of the input, where the current cumulative sum is independent of the cumulative sums of previous inputs.

The output has the same size, dimension, frame status, data type, and complexity as the input. The mth output row is the sum 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 summing along columns.

Summing Along Rows

When the Sum input along parameter is set to Rows, the block computes the cumulative sum of the row elements, where the current cumulative sum is independent of the cumulative sums of previous inputs.

The output has the same size, dimension, frame status, and data type as the input. The nth output column is the sum 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 summing along rows.

Dialog Box

Sum input along
The dimension along which to compute the cumulative summations. The options allow you to sum along Channels (running sum), Columns, and Rows. For more information, see the following sections:
Reset port
Determines the reset event that causes the block to reset the sum 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 Sum input along parameter to Channels (running sum). For more information, see Resetting the Cumulative Sum Along Channels.

Supported Data Types

Input and Output Ports
Supported Data Types
Data input port, In
  • Double-precision floating point
  • Single-precision floating point
Reset input port, Rst
All built-in Simulink data types:
  • Double-precision floating point
  • Single-precision floating point
  • Boolean
  • 8-, 16-, and 32-bit signed integers
  • 8-, 16-, and 32-bit unsigned integers
Output port
Always has same data type as data input

To learn how to convert to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.

See Also

Cumulative Product
DSP Blockset
Difference
DSP Blockset
Matrix Sum
DSP Blockset
cumsum
MATLAB


  Cumulative Product dB Conversion