# Convolution

Convolution of two inputs

• Library:
• DSP System Toolbox / Signal Operations

• ## Description

The Convolution block convolves the first dimension of an N-D input array u with the first dimension of an N-D input array v. The block can also convolve a column vector with the first-dimension of an N-D input array.

The general equation for convolution is:

`$y\left(k\right)=\sum _{n}^{}u\left(n-k\right)v\left(k\right)$`

Two DSP System Toolbox™ blocks can be used for convolving two input signals:

The Convolution block assumes that all elements of u and v are available at each Simulink® time step and computes the entire convolution at every step.

The Discrete FIR Filter block can be used for convolving signals in situations where all elements of v is available at each time step, but u is a sequence that comes in over the life of the simulation. When you use the Discrete FIR Filter block, the convolution is computed only once.

To determine which block best fits your needs, see Selecting the Appropriate Convolution Block.

## Ports

### Input

expand all

First input u specified as a scalar, vector, matrix, or N-D array. When both inputs are real, the output is real. When one or both inputs are complex, the output is complex. All the input port dimensions for both the inputs, except the first dimension, must have the same value.

Inputs u and v are zero when indexed outside their valid ranges.

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

Second input v specified as a scalar, vector, matrix, or N-D array. When both inputs are real, the output is real. When one or both inputs are complex, the output is complex. All the input port dimensions for both the inputs, except the first dimension, must have the same value.

Inputs u and v are zero when indexed outside their valid ranges.

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

### Output

expand all

Convolved signal, returned as a scalar, vector, matrix, or N-D array depending on the input signals. When both inputs are real, the output is real. When one or both inputs are complex, the output is complex. Inputs u and v are zero when indexed outside of their valid ranges. For more details on how the convolved signal changes based on the inputs, see More About.

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

## Parameters

expand all

### Main Tab

Set the domain in which the block computes convolutions:

• `Time` — The block computes in the time domain, which minimizes memory use.

• `Frequency` — The block computes in the frequency domain, which might require fewer computations than computing in the time domain, depending on the input length.

• `Fastest` — The block computes in the domain that minimizes the number of computations.

Fixed-point signals are only supported in the time domain. When inputting fixed-point signals, make sure you set the Computation domain parameter to `Time`.

### Data Types Tab

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

Note

The Rounding mode and Saturate on integer overflow parameters have no effect on numerical results when all these conditions are met:

• Product output data type is ```Inherit: Inherit via internal rule```.

• Accumulator data type is ```Inherit: Inherit via internal rule```.

• Output data type is ```Inherit: Same as accumulator```.

With these data-type settings, the block operates in a full-precision 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 Handing for fixed-point operations.

Note

The Rounding mode and Saturate on integer overflow parameters have no effect on numerical results when all these conditions are met:

• Product output data type is ```Inherit: Inherit via internal rule```.

• Accumulator data type is ```Inherit: Inherit via internal rule```.

• Output data type is ```Inherit: Same as accumulator```.

With these data-type settings, the block operates in a full-precision mode.

Product output specifies the data type of the output of a product operation in the Convolution block.

• `Inherit: Inherit via internal rule` — The block inherits the product output data type based on an internal rule. For more information on this rule, see Inherit via Internal Rule.

• `Inherit: Same as first input` — The block specifies the product output data type to be the same as the first 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 Product output data type by using the Data Type Assistant. To use the assistant, click the button .

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

For more information on the product output data type, see Multiplication Data Types and Fixed-Point Conversion in Extended Capabilities.

Accumulator specifies the data type of the output of an accumulation operation in the Convolution block.

• `Inherit: Inherit via internal rule` — The block inherits the accumulator data type based on an internal rule. For more information on this rule, see Inherit via Internal Rule.

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

• `Inherit: Same as product output` — The block specifies the accumulator data type to be the same as the product output 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. To use the assistant, click the button .

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

For a diagrammatic representation on how to use the accumulator data type in this block, see Fixed-Point Conversion in Extended Capabilities.

Output specifies the data type of the output of the Convolution block.

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

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

• `Inherit: Same as product output` — The block specifies the output data type to be the same as the product output 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. To use the assistant, click the button .

For more information on the output data type, see Fixed-Point Conversion in Extended Capabilities.

Specify the minimum value the block can output. Simulink 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 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 in the block dialog box.

## Block Characteristics

 Data Types `double` | `fixed point` | `integer` | `single` Direct Feedthrough `no` Multidimensional Signals `no` Variable-Size Signals `no` Zero-Crossing Detection `no`

expand all

## Extended Capabilities

### Blocks

Introduced before R2006a

## Support Get trial now