Main Content

dsp.CumulativeSum

(To be removed) Cumulative sum of channel, column, or row elements

dsp.CumulativeSumwill be removed in a future release. Use thecumsumfunction instead. For more information, seeCompatibility Considerations.

Description

Thedsp.CumulativeSumSystem object™ computes the cumulative sum of channel, column, or row elements.

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

  1. Create thedsp.CumulativeSumobject and set its properties.

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

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

Creation

Description

example

csum= dsp.CumulativeSumreturns 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 arenontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and thereleasefunction unlocks them.

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

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

Specify the computation dimension asChannels (running sum),Rows, orColumns.

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

指定事件的复位输入端口resets the cumulative sum asRising edge,Falling edge,Either edge, orNon-zero.

Dependencies

This property applies when you set theResetInputPortproperty totrue.

Fixed-Point Properties

Specify the rounding method as one ofCeiling,Convergent,Floor,Nearest,Round,Simplest, orZero.

Specify the overflow action as one ofWraporSaturate.

Specify the accumulator fixed-point data type asSame as inputorCustom.

Specify the accumulator fixed-point type as a scalednumerictype(Fixed-Point Designer)object with aSignednessofAuto.

Dependencies

This property applies when you set theAccumulatorDataTypeproperty toCustom.

Specify the output fixed-point data type asSame as accumulator,Same as input, orCustom.

Specify the output fixed-point type as a scalednumerictype(Fixed-Point Designer)object with aSignednessofAuto.

Dependencies

This property applies when you set theOutputDataTypeproperty toCustom.

Usage

Description

example

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

y= csum(x,r)resets the System object state based on theResetConditionproperty value and the value of the reset signal,r. You can only reset the state if theResetInputPortproperty istrue.

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 theResetCondition.

Dependencies

This input is applicable only whenDimensionis set to'Channels (running sum)'andResetInputPortis set totrue.

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 namedobj, use this syntax:

release(obj)

expand all

step RunSystem objectalgorithm
release Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem object

Examples

collapse all

Note

If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example,obj(x)becomesstep(obj,x).

Use thedsp.CumulativeSumobject to compute the cumulative sum of a matrix.

csum = dsp.CumulativeSum; x = magic(2)
x =2×21 3 4 2
y = csum(x)
y =2×21 3 5 5

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

Algorithms

This object implements the algorithm, inputs, and outputs described on theCumulative Sumblock reference page. The object properties correspond to the block properties, except theReset portblock parameter corresponds to both theResetConditionand theResetInputPortobject properties.

Extended Capabilities

Version History

Introduced in R2012a

expand all

Warns starting in R2021b

See Also

Functions