Sum, Add, Subtract, Sum of Elements - Add or subtract inputs

Library

Math Operations

Description

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

Data Type Support

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.

Parameters and Dialog Box

The Main pane of the Sum block dialog appears as follows:

Icon shape

Designate the icon shape of the block.

List of signs

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.

Sum over (Sum of Elements block)

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.

Dimension (Sum of Elements block)

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.

Sample time (-1 for inherited)

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:

Require all inputs to have the same data type

Select this parameter to require that all inputs must have the same data type.

Accumulator data type

Specify the accumulator data type. You can set it to:

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.

Output minimum

Specify the minimum value that the block should output. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:

Output maximum

Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:

Output data type

Specify the output data type. You can set it to:

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.

Lock output scaling against changes by the autoscaling tool

Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.

Round integer calculations toward

Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink® Fixed Point™ User's Guide.

Saturate on integer overflow

Select to have overflows saturate.

Characteristics

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

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS