主要内容

convn

N-D convolution

Description

example

C= convn(A,B)returns then维卷积数组AB

example

C= convn(A,B,shape)returns a subsection of the convolution according toshape。For example,C = convn(A,B,'same')returns the central part of the convolution, which is the same size asA

Examples

collapse all

You can control the size of the output of theconvnfunction. For example, the'相同的'option trims the outer part of the convolution and returns only the central part, which is the same size as the input.

换一个随机的2 x-3-by-2阵列Awith a 2-by-2-by-2 kernelB。The result is a 3-by-4-by-3 array, which is尺寸(a) +大小(b)-1

A = rand(2,3,2); B = 0.25*ones(2,2,2); C = convn(A,B)
C = C(:,:,1) = 0.2037 0.2354 0.1898 0.1581 0.4301 0.6902 0.4426 0.1825 0.2264 0.4548 0.2527 0.0244 C(:,:,2) = 0.2733 0.5444 0.4686 0.1975 0.6365 1.3772 1.2052 0.4645 0.3632 0.8327 0.7366 0.2670 C(:,:,3) = 0.0696 0.3090 0.2788 0.0394 0.2063 0.6869 0.7627 0.2821 0.1367 0.3779 0.4839 0.2426
sizec = size(a) + size(b)-1
sizeC =1×33 4 3

Return the central part of the convolution, which is the same size asA

C = convn(A,B,'相同的')
C = C(:,:,1) = 1.3772 1.2052 0.4645 0.8327 0.7366 0.2670 C(:,:,2) = 0.6869 0.7627 0.2821 0.3779 0.4839 0.2426

Input Arguments

collapse all

输入阵列,指定为向量,矩阵或多维数组。

Data Types:double|single|int8|INT16|INT32|int64|uint8|uint16|uint32|uint64|logical
Complex Number Support:Yes

Second input array, specified as a vector, a matrix, or a multidimensional array to convolve withA。数组Bdoes not have to be the same size asA

Data Types:double|single|int8|INT16|INT32|int64|uint8|uint16|uint32|uint64|logical
Complex Number Support:Yes

Subsection of the convolution, specified as one of these values:

  • '满的'— Return the full N-D convolution.

  • '相同的'— Return the central part of the convolution, which is the same size asA

  • '有效的'— Return only parts of the convolution that are computed without zero-padded edges.

Output Arguments

collapse all

N-D convolution, returned as a vector, a matrix, or a multidimensional array. IfAB具有相同数量的尺寸,完整的卷积C = convn(A,B)has sizesize(A)+size(B)-1

When one or both ofABare of typesingle,然后输出是类型的single。除此以外,convnconverts inputs to typedouble并返回类型double

Data Types:double|single

More About

collapse all

N-D卷积

For discrete,N-dimensional variablesAB,以下方程式定义了AB:

C ( j 1 , j 2 , 。。。 , j N ) = k 1 k 2 。。。 k N A ( k 1 , k 2 , 。。。 , k N ) B ( j 1 k 1 + 1 , j 2 k 2 + 1 , 。。。 , j N k N + 1 )

每一个kiruns over all values that lead to legal subscripts ofAB

Extended Capabilities

C/C++ Code Generation
使用MATLAB®CODER™生成C和C ++代码。

Version History

在R2006a之前引入

See Also

|