Main Content

dsp.CumulativeSum

(Removed) Cumulative sum of channel, column, or row elements

dsp.CumulativeSum has been removed. Use the cumsum function instead. For more information, see Compatibility Considerations.

Description

The dsp.CumulativeSum System object™ computes the cumulative sum of channel, column, or row elements.

To compute the cumulative sum of channel, column, or row elements:

  1. Create the dsp.CumulativeSum object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

example

csum = dsp.CumulativeSum returns a cumulative sum System object, csum, which computes the running cumulative sum for each channel in the input.

csum = dsp.CumulativeSum(Name,Value) returns a cumulative sum object, csum, with each specified property set to the specified value. Enclose each property name in single quotes. Unspecified properties have default values.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Specify the computation dimension as Channels (running sum), Rows, or Columns.

Set this property to true to enable resetting the cumulative sum. When you set this property to true, you also specify a reset input to the object algorithm to reset the cumulative sum.

Specify the event on the reset input port that resets the cumulative sum as Rising edge, Falling edge, Either edge, or Non-zero.

Dependencies

This property applies when you set the ResetInputPort property to true.

Fixed-Point Properties

Specify the rounding method as one of Ceiling, Convergent, Floor , Nearest, Round, Simplest, or Zero.

Specify the overflow action as one of Wrap or Saturate.

Specify the accumulator fixed-point data type as Same as input or Custom.

Specify the accumulator fixed-point type as a scaled numerictype (Fixed-Point Designer) object with a Signedness of Auto.

Dependencies

This property applies when you set the AccumulatorDataType property to Custom.

Specify the output fixed-point data type as Same as accumulator, Same as input, or Custom.

Specify the output fixed-point type as a scaled numerictype (Fixed-Point Designer) object with a Signedness of Auto.

Dependencies

This property applies when you set the OutputDataType property to Custom.

Usage

Description

example

y = csum(x) computes the cumulative sum along the specified dimension for the input x.

y = csum(x,r) resets the System object state based on the ResetCondition property value and the value of the reset signal, r. You can only reset the state if the ResetInputPort property is true.

Input Arguments

expand all

Data input, specified as a vector or a matrix.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Reset signal used to reset the running cumulative sum, specified as a scalar. The object resets the running cumulative sum if the reset signal satisfies the ResetCondition.

Dependencies

This input is applicable only when Dimension is set to 'Channels (running sum)' and ResetInputPort is set to true.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical | fi

Output Arguments

expand all

Cumulative sum of the input signal, returned as a vector or a matrix.

The size, data type, and complexity characteristics of the output signal match that of the input signal.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Use the dsp.CumulativeSum object to compute the cumulative sum of a matrix.

 csum = dsp.CumulativeSum;
 x = magic(2)
x = 2×2

     1     3
     4     2

 y = csum(x)
y = 2×2

     1     3
     5     5

The cumulative sum is computed column-wise along each channel.

Algorithms

This object implements the algorithm, inputs, and outputs described on the Cumulative Sum block reference page. The object properties correspond to the block properties, except the Reset port block parameter corresponds to both the ResetCondition and the ResetInputPort object properties.

Extended Capabilities

Version History

Introduced in R2012a

expand all

R2023a: dsp.CumulativeSum System object has been removed

The dsp.CumulativeSum System object has been removed. Use the cumsum function instead.

Update Code

This table shows how to update existing code to use the cumsum function.

Discouraged UsageRecommended Replacement

Column-wise cumulative sum

By default, the object computes the running sum along the columns (channels) since the Dimension property of the object is set to 'Channels (running sum)'.

csum = dsp.CumulativeSum;
x = magic(2)
x = 2×2

     1     3
     4     2

y = csum(x)
y = 2×2

    1     3
    5     5

Row-wise cumulative sum

To compute row-wise cumulative sum, set the Dimension property to 'Rows' and run the object algorithm again.

release(csum);
csum.Dimension = 'Rows';
y = csum(x)
y = 2×2

   1     4
   4     6

Column-wise cumulative sum

y = cumsum(x,1)
y = 2×2

    1     3
    5     5

Row-wise cumulative sum

y = cumsum(x,2)
y = 2×2

   1     4
   4     6

See Also

Functions