| Simulink® | ![]() |
Math Operations

The Sum block performs addition or subtraction on its inputs. This block can add or subtract scalar, vector, or matrix inputs. It can also collapse the elements of a signal.
You specify the operations of the block with the List of signs parameter. Plus (+), minus (-), and spacer (|) characters indicate the operations to be performed on the inputs:
If there are two or more inputs, then the number of + and - characters must equal the number of inputs. For example, "+-+" requires three inputs and configures the block to subtract the second (middle) input from the first (top) input, and then add the third (bottom) input.
All nonscalar inputs must have the same dimensions. Scalar inputs will be expanded to have the same dimensions as the other inputs.
A spacer character creates extra space between ports on the block's icon.
If only addition of all inputs is required, then a numeric parameter value equal to the number of inputs can be supplied instead of "+" characters.
If only one input port, a single "+" or "-" will collapse the element using the specified operation.
If input or output signals of a Sum block specify integer or fixed-point data types, the block first converts the input data type(s) to its accumulator data type, and then performs the specified operations. The block converts the result to its output data type using the specified rounding and overflow modes.
The Sum block accepts real or complex signals of any data type supported by Simulink® software, including fixed-point data types. The inputs may be of different data types unless you select the Require all inputs to have the same data type parameter.
For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink® in the Simulink documentation.
The Main pane of the Sum block dialog appears as follows:

Designate the icon shape of the block.
Enter as many plus (+) and minus (-) characters as there are inputs. Addition is the default operation, so if you only want to add the inputs, enter the number of input ports. For a single vector input, "+" or "-" will collapse the vector using the specified operation.
You can manipulate the positions of the input ports on the block by inserting spacers (|) between the signs in the List of signs parameter. For example, "++|--" creates an extra space between the second and third input ports.
This becomes visible on the Main pane when List of signs contains only one element.
Select All dimensions to sum all input elements, yielding a scaler.
Select Specified dimension to display the Dimension parameter, where you specify the dimension over which the operation is to be performed.
Specify the dimension over which the operation is to be performed.
The block follows the same summation rules as the MATLAB® sum function.
For example, for a 2 x 3 matrix U, setting Specified dimension to 1 results in the output Y being computed as:
![]()
Setting Specified dimension to 2 results in Y being computed as:
![]()
If the specified dimension is greater than the dimension of the input, Simulink software reports an error.
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the online documentation for more information.
The Signal Attributes pane of the Sum block dialog appears as follows:

Select this parameter to require that all inputs must have the same data type.
Specify the accumulator data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, float('single')
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Accumulator
data type parameter.
See Using the Data Type Assistant for more information.
Specify the minimum value that the block should output. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via back propagation
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, float('single')
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output
data type parameter.
See Specifying Block Output Data Types for more information.
Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.
Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink® Fixed Point™ User's Guide.
Select to have overflows saturate.
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes |
States | 0 |
Dimensionalized | Yes |
Multidimensionalized | Yes, only along the specified dimension |
Zero Crossing | No |
![]() | Subsystem, Atomic Subsystem, CodeReuse Subsystem | Switch | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |