conv

Convolution of two vectors, or polynomial multiplication.

Category: Mathematics > Elementary Math

Syntax

w = conv(u, v)

Returns the full convolution, of length numel(u) + numel(v) - 1.

w = conv(u, v, shape)

Returns a section of the convolution: 'full' (default), 'same' (central part, same size as u) or 'valid' (only where the vectors fully overlap).

Description

Convolution slides one vector across the other, multiplying and adding. It is the output of a linear filter with impulse response v applied to the signal u. It is also polynomial multiplication: conv([1 2 3], [1 1]) multiplies x^2 + 2x + 3 by x + 1 and gives [1 3 5 3].

The reverse operation is deconv. For 2-D data use conv2.

Input arguments

u, v
Vectors. If both are polynomial coefficient vectors, the result is the coefficient vector of their product.
shape
'full', 'same' or 'valid'.

Output arguments

w
Convolution vector. It is a column if the first input u is a column, otherwise a row.

Example

Polynomial product and shapes

conv([1 2 3], [1 1])
conv([1 2 3], [1 1 1], 'same')
conv([1 2 3], [1 1 1], 'valid')
Output
ans = 1×4

     1     3     5     3
ans = 1×3

     3     6     5
ans = 6

See also

deconv conv2 filter polyval