Main Content

Cumulative Sum

Cumulative sum of channel, column, or row elements

  • Library:
  • DSP System Toolbox / Math Functions / Math Operations

  • Cumulative Sum block

Description

The Cumulative Sum block computes the cumulative sum along the specified dimension of the input or across time (running sum).

Ports

Input

expand all

Input, specified as a vector or as matrix inputs containing real or complex values.

This port is unnamed until you select a non-None value for the Reset port parameter.

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

The optional reset port, Rst, accepts scalar values, which can be any built-in Simulink® data type including boolean. The rate of the input to the Rst port must be the same or slower than that of the input data signal. The sample time of the input to the Rst port must be a positive integer multiple of the input sample time.

This port is unnamed until you select a non-None value for the Reset port parameter.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean

Output

expand all

Cumulative sum of input, specified as a vector or a matrix.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Parameters

expand all

Main

Specify the dimension along which to compute the cumulative summations. You can choose to sum along Channels (running sum), Columns, or Rows. For more information, see these sections:

Specify how the block processes the input when computing the running sum along the channels of the input. You can set this parameter to one of these options:

  • Columns as channels (frame based) — The block treats each column of the input as a separate channel.

  • Elements as channels (sample based) — The block treats each element of the input as a separate channel.

Dependencies

This parameter is available only when you set the Sum input along parameter to Channels (running sum).

Determines the reset event that causes the block to reset the sum along channels. The rate of the input to the Rst port must be the same or slower than that of the input data signal. The sample time of the input to the Rst port must be a positive integer multiple of the input sample time. For more information, see Resetting the Running Sum.

Dependencies

This parameter is available only when you set the Sum input along parameter to Channels (running sum).

Data Types

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. All internal data types are floating point.

Specify the rounding mode for fixed-point operations as one of the following:

  • Floor

  • Ceiling

  • Convergent

  • Nearest

  • Round

  • Simplest

  • Zero

For more details, see rounding mode.

When you select this parameter, the block saturates the result of its fixed-point operation. When you clear this parameter, the block wraps the result of its fixed-point operation. For details on saturate and wrap, see overflow mode for fixed-point operations.

Accumulator specifies the data type of the output of an accumulation operation in the Cumulative Sum block. For illustrations on how to use the accumulator data type in this block, see the 'Fixed-Point Conversion' section in Extended Capabilities.

  • Inherit: Same as input — The block specifies the accumulator data type to be the same as the input data type.

  • fixdt([],16,0) — The block specifies an autosigned, binary-point, scaled, fixed-point data type with a word length of 16 bits and a fraction length of 0.

Alternatively, you can set the Accumulator data type by using the Data Type Assistant. Click the Show data type assistant button.

For more information, see Specify Data Types Using Data Type Assistant (Simulink).

Output specifies the data type of the output of the Cumulative Sum block. For more information on the output data type, see the 'Fixed-Point Conversion' section in Extended Capabilities.

  • Inherit: Same as input — The block specifies the output data type to be the same as the input data type.

  • Inherit: Same as accumulator — The block specifies the output data type to be the same as the accumulator data type.

  • fixdt([],16,0) — The block specifies an autosigned, binary-point, scaled, fixed-point data type with a word length of 16 bits and a fraction length of 0.

Alternatively, you can set the Output data type by using the Data Type Assistant. Click the Show data type assistant button.

For more information on the data type assistant, see Specify Data Types Using Data Type Assistant (Simulink).

Specify the minimum value the block can output. Simulink software uses this minimum value to perform:

  • Simulation range checking. See Specify Signal Ranges (Simulink).

  • Automatic scaling of fixed-point data types.

Specify the maximum value the block can output. Simulink software uses this maximum value to perform:

  • Simulation range checking. See Specify Signal Ranges (Simulink).

  • Automatic scaling of fixed-point data types.

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

Block Characteristics

Data Types

double | fixed point | integer | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

More About

expand all

Extended Capabilities

See Also

Functions

Blocks

Introduced before R2006a