# Array-Vector Subtract

Subtract vector from array along specified dimension

## Library

Math Functions / Matrices and Linear Algebra / Matrix Operations

`dspmtrx3`

## Description

The Array-Vector Subtract block subtracts the values in the input vector V from the values in the specified dimension of the N-dimensional input array A.

The length of the input V must be the same as the length of the specified dimension of A. The Array-Vector Subtract block subtracts each element of V from the corresponding element along that dimension of A.

Consider a 3-dimensional M-by-N-by-P input array A(i,j,k) and an N-by-1 input vector V. When the Subtract along dimension parameter is set to `2`, the output of the block Y(i,j,k) is

`$Y\left(i,j,k\right)=A\left(i,j,k\right)-V\left(j\right)$`

where

`$\begin{array}{l}1\le i\le M\\ 1\le j\le N\\ 1\le k\le P\end{array}$`

The output of the Array-Vector Subtract block is the same size as the input array, A. This block accepts real and complex floating-point and fixed-point inputs.

### Fixed-Point Data Types

The following diagram shows the data types used within the Array-Vector Subtract block for fixed-point signals.

When you specify the vector V on the Main pane of the block mask, you must specify the data type and scaling properties of its elements in the Vector (V) parameter on the Data Types tab. When the vector comes in through the block port, its elements inherit their data type and scaling from the driving block.

The output of the subtractor is in the accumulator data type.

You can set the vector, accumulator, and output data types in the block dialog as discussed below.

## Parameters

Main Tab

Subtract along dimension

Specify the dimension along which to subtract the elements of vector V from the input array A.

Vector (V) source

Specify the source of the vector, V. The vector can come from the `Input port` or from a `Dialog parameter`.

Vector (V)

Specify the vector, V. This parameter is visible only when you select `Dialog parameter` for the Vector (V) source parameter.

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, and all internal data types are floating point.

Rounding mode

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.

Note

The Rounding mode and Saturate on integer overflow settings have no effect on numerical results when both of these conditions are met:

• Accumulator is ```Inherit: Inherit via internal rule```

• Output is ```Inherit: Same as accumulator```

With these data type settings, the block is effectively operating in full precision mode.

Saturate on integer overflow

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.

Vector (V)

Use this parameter to specify the word and fraction lengths for the elements of the vector, V. You can set this parameter to:

• A rule that inherits a data type, for example, ```Inherit: Same word length as input```

• An expression that evaluates to a valid data type, for example, `fixdt(1,16,0)`

Click the button to display the Data Type Assistant, which helps you set the Accumulator parameter.

Note

The Vector (V) parameter on the Data Types pane is only visible when you select `Dialog parameter` for the Vector (V) source parameter on the Main pane of the block mask. When the vector comes in through the block's input port, the data type and scaling of its elements are inherited from the driving block.

Accumulator

Specify the accumulator data type. See Fixed-Point Data Types for illustrations depicting the use of the accumulator data type in this block. You can set this parameter to:

• A rule that inherits a data type, for example, `Inherit: Inherit via internal rule`. For more information on this rule, see Inherit via Internal Rule.

• A rule that inherits a data type, for example, `Inherit: Same as first input`.

• An expression that evaluates to a valid data type, for example, `fixdt(1,16,0)`

Click the button to display the Data Type Assistant, which helps you set the Accumulator parameter.

Output

Specify the output data type. See Fixed-Point Data Types for illustrations depicting the use of the output data type in this block. You can set it to:

• A rule that inherits a data type, for example, `Inherit: Same as accumulator`

• A rule that inherits a data type, for example, `Inherit: Same as first input`.

• An expression that evaluates to a valid data type, for example, `fixdt(1,16,0)`

Click the button to display the Data Type Assistant, which helps you set the Output parameter.

Minimum

Specify the minimum value that the block should output. The default value is `[]` (unspecified). Simulink® uses this value to perform:

• Simulation range checking (see Specify Signal Ranges (Simulink))

• Automatic scaling of fixed-point data types

Maximum

Specify the maximum value that the block should output. The default value is `[]` (unspecified). Simulink uses this value to perform:

• Simulation range checking (see Specify Signal Ranges (Simulink))

• Automatic scaling of fixed-point data types

Lock data type settings against changes by the fixed-point tools

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

### Vector (V) Data Type

Mode

Select how you would like to specify the data type properties of the Vector (V) data type. You can choose:

• `Inherit` — Lets you specify a rule for inheriting a data type, for example, ```Inherit: Inherit via internal rule```

• `Fixed point` — Lets you specify the fixed-point attributes of the data type.

• `Expression` — Lets you specify an expression that evaluates to a valid data type, for example, `fixdt(1,16,0)`

Signedness

Specify the Signedness for the Vector (V) data type.

Scaling

Specify the Scaling for the Vector (V) data type.

For more information see Scaling in the DSP System Toolbox™ User's Guide.

Word length

Specify the Word length for the Vector (V) data type.

Fraction length

Specify the Fraction length for the Vector (V) data type.

Data type override

Specify the data type override mode. You can select one of the following options:

• `Inherit` — Inherits the data type override setting specified for the model.

• `Off` — Ignores the data type override setting specified for the model and uses the fixed-point data type you specify

This parameter appears only when you set the Mode parameter to `Built in` or `Fixed Point`. For more information, see Specify Data Types Using Data Type Assistant (Simulink).

### Accumulator Data Type Assistant Parameters

Mode

Select how you would like to specify the data type properties of the Accumulator data type. You can choose:

• `Inherit` — Lets you specify a rule for inheriting a data type, for example, ```Inherit: Inherit via internal rule```

• `Fixed point` — Lets you specify the fixed-point attributes of the data type.

• `Expression` — Lets you specify an expression that evaluates to a valid data type, for example, `fixdt(1,16,0)`

Signedness

Specify the Signedness for the Accumulator data type.

Scaling

Specify the Scaling for the Accumulator data type.

For more information see Scaling in the DSP System Toolbox User's Guide.

Word length

Specify the Word length for the Accumulator data type.

Fraction length

Specify the Fraction length for the Accumulator data type.

Data type override

Specify the data type override mode. You can select one of the following options:

• `Inherit` — Inherits the data type override setting specified for the model.

• `Off` — Ignores the data type override setting specified for the model and uses the fixed-point data type you specify

This parameter appears only when you set the Mode parameter to `Built in` or `Fixed Point`. For more information, see Specify Data Types Using Data Type Assistant (Simulink).

### Output Data Type Assistant Parameters

Mode

Select how you would like to specify the data type properties of the Output data type. You can choose:

• `Inherit` — Lets you specify a rule for inheriting a data type, for example, ```Inherit: Inherit via internal rule```

• `Fixed point` — Lets you specify the fixed-point attributes of the data type.

• `Expression` — Lets you specify an expression that evaluates to a valid data type, for example, `fixdt(1,16,0)`

Signedness

Specify the Signedness for the Output data type.

Scaling

Specify the Scaling for the Output data type.

For more information see Scaling in the DSP System Toolbox User's Guide.

Word length

Specify the Word length for the Output data type.

Fraction length

Specify the Fraction length for the Output data type.

Data type override

Specify the data type override mode. You can select one of the following options:

• `Inherit` — Inherits the data type override setting specified for the model.

• `Off` — Ignores the data type override setting specified for the model and uses the fixed-point data type you specify

This parameter appears only when you set the Mode parameter to `Built in` or `Fixed Point`. For more information, see Specify Data Types Using Data Type Assistant (Simulink).

## Supported Data Types

PortSupported Data Types

A

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed only)

• 8-, 16-, and 32-bit signed integers

V

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed only)

• 8-, 16-, and 32-bit signed integers

Output

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed only)

• 8-, 16-, and 32-bit signed integers

## Version History

Introduced in R2007b