Convolution of two inputs
Signal Operations
dspsigops
The Convolution block convolves the first dimension of an ND input array u, with the first dimension of an ND input array v. The block can also independently convolve a column vector with the firstdimension of an ND input array.
The general equation for convolution is
$$y(k)={\displaystyle \sum _{n}^{}u(nk)h(k)}$$
There are two DSP System Toolbox™ blocks that can be used for this purpose:
Convolution
The Convolution block assumes that all of u and h are available at each Simulink^{®} time step, and computes the entire convolution at every one.
The Discrete FIR Filter block can be used for convolving signals in situations where all of h 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.
Use the following questions to help you determine which block best fits your needs:
Question  Answer  Recommended Block(s) 

How many convolutions do you intend to perform?  Many convolutions, one at each time step 

One convolution over the life of the simulation 
 
How long are your input sequences?  Both sequences have a finite length 

One sequence has an infinite (not predetermined) length 
 
How many of the inputs are scalar streams?  None 

One or both 

The block always computes the convolution of two ND input arrays along the first dimension. When both inputs are ND arrays, the size of their first dimension can differ, but the size of all other dimensions must be equal. For example, when u is an M_{u}byNbyP array, and v is an M_{v}byNbyP array, the output is an (M_{u}+M_{v}–1)byNbyP array.
When the input to the Convolution block is a M_{u}byN matrix u and an M_{v}byN matrix v, the output, y, is a (M_{u}+M_{v}–1)byN matrix whose jth column has the following elements
$$\begin{array}{cc}{y}_{i,j}={\displaystyle \sum _{k=0}^{\mathrm{max}({M}_{u},{M}_{v})1}{u}_{k,j}{v}_{\left(ik\right),j}}& 0\le i\le \left({M}_{u}+{M}_{v}2\right)\end{array}$$
Inputs u and v are zero when indexed outside of their valid ranges. When both inputs are real, the output is real; when one or both inputs are complex, the output is complex.
When one input is a column vector and the other is an ND array, the block independently convolves the vector with the first dimension of the ND input array. For example, when u is a M_{u}by1 column vector and v is an M_{v}byN matrix, the output is an (M_{u}+M_{v}–1)byN matrix whose jth column has the following elements
$$\begin{array}{cc}{y}_{i,j}={\displaystyle \sum _{k=0}^{\mathrm{max}({M}_{u},{M}_{v})1}{u}_{k}{v}_{\left(ik\right),j}}& 0\le i\le \left({M}_{u}+{M}_{v}2\right)\end{array}$$
The Convolution block also accepts two column vector inputs. When u and v are column vectors with lengths M_{u} and M_{v}, the Convolution block performs the vector convolution
$$\begin{array}{cc}{y}_{i}={\displaystyle \sum _{k=0}^{\mathrm{max}({M}_{u},{M}_{v})1}{u}_{k}{v}_{\left(ik\right)}}& 0\le i\le \left({M}_{u}+{M}_{v}2\right)\end{array}$$
The output is a (M_{u}+M_{v}–1)by1 column vector.
The following diagram shows the data types used within the Convolution block for fixedpoint signals (time domain only).
You can set the product output, accumulator, and output data types in the block dialog as discussed in the next section.
The output of the multiplier is in the product output data type when the input is real. When the input is complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed, see Multiplication Data Types.
Note: When one or both of the inputs are signed fixedpoint signals, all internal block data types are signed fixed point. The internal block data types are unsigned fixed point only when both inputs are unsigned fixedpoint signals. 
The Main pane of the Convolution block dialog appears as follows.
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, which minimizes the number of computations.
The Data Types pane of the Convolution block dialog appears as follows.
Note:
Fixedpoint signals are only supported for the time domain.
To use the parameters on this pane, make sure 
Select the rounding mode for fixedpoint operations.
Note: The Rounding mode and Saturate on integer overflow settings have no effect on numerical results when all the following conditions exist:
With these data type settings, the block is effectively operating in full precision mode. 
When you select this check box, the block saturates the result
of its fixedpoint operation. When you clear this check box, the block
wraps the result of its fixedpoint operation. By default, this check
box is cleared. For details on saturate
and wrap
,
see overflow
mode for fixedpoint operations.
Specify the product output data type. See FixedPoint Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block. You can set it 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.
An expression that evaluates to a valid data type,
for example, fixdt([],16,0)
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Product output data type parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
Specify the accumulator data type. See FixedPoint 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.
An expression that evaluates to a valid data type,
for example, fixdt([],16,0)
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Accumulator data type parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
Specify the output data type. See FixedPoint 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
An expression that evaluates to a valid data type,
for example, fixdt([],16,0)
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.
See Control Signal Data Types (Simulink) for more information.
Specify the minimum value that the block should output. The
default value is []
(unspecified). Simulink software
uses this value to perform:
Simulation range checking (see Signal Ranges (Simulink))
Automatic scaling of fixedpoint data types
Specify the maximum value that the block should output. The
default value is []
(unspecified). Simulink software
uses this value to perform:
Simulation range checking (see Signal Ranges (Simulink))
Automatic scaling of fixedpoint data types
Select this parameter to prevent the fixedpoint tools from overriding the data types you specify on the block mask.
Port  Supported Data Types 

Input 

Output 
