C = convn(A,B,shape) returns
a subsection of the convolution according to shape.
For example, C = convn(A,B,'same') returns the
central part of the convolution, which is the same size as A.
You can control the size of the output of the convn function. For example, the 'same' option trims the outer part of the convolution and returns only the central part, which is the same size as the input.
Convolve a random 2-by-3-by-2 array A with a 2-by-2-by-2 kernel B. The result is a 3-by-4-by-3 array, which is size(A) + size(B) - 1.
A = rand(2,3,2);
B = 0.25*ones(2,2,2);
C = convn(A,B)
A — Input array vector | matrix | multidimensional array
Input array, specified as vector, a matrix, or a multidimensional
array.
Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical Complex Number Support: Yes
B — Second input array vector | matrix | multidimensional array
Second input array, specified as a vector, a matrix, or a multidimensional
array to convolve with A. The array B does
not have to be the same size as A.
Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical Complex Number Support: Yes
C — N-D convolution vector | matrix | multidimensional array
N-D convolution, returned as a vector, a matrix, or a multidimensional
array. If A and B have the same
number of dimensions, the full convolution C = convn(A,B) has
size size(A)+size(B)-1.
When one or both of A and B are
of type single, then the output is of type single.
Otherwise, convn converts inputs to type double and
returns type double.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.