convn
N-D convolution
Description
Examples
3-D Convolution
You can control the size of the output of theconvn
function. 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阵列A
with 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
A
—输入数组
vector|matrix|多维阵列
输入阵列,指定为向量,矩阵或多维数组。
Data Types:double
|single
|int8
|INT16
|INT32
|int64
|uint8
|uint16
|uint32
|uint64
|logical
Complex Number Support:Yes
B
—Second input array
vector|matrix|多维阵列
Second input array, specified as a vector, a matrix, or a multidimensional array to convolve withA
。数组B
does 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
shape
—Subsection of convolution
'满的'
(default) |'相同的'
|'有效的'
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
C
— N-D convolution
vector | matrix | multidimensional array
N-D convolution, returned as a vector, a matrix, or a multidimensional array. IfA
和B
具有相同数量的尺寸,完整的卷积C = convn(A,B)
has sizesize(A)+size(B)-1
。
When one or both ofA
和B
are of typesingle
,然后输出是类型的single
。除此以外,convn
converts inputs to typedouble
并返回类型double
。
Data Types:double
|single
More About
N-D卷积
For discrete,N-dimensional variablesA和B,以下方程式定义了A和B:
每一个kiruns over all values that lead to legal subscripts ofA和B。
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
Usage notes and limitations:
If
shape
is'满的'
(默认),然后输入A
和B
must not be empty and only one them can be a tall array.If
shape
is'相同的'
或者'有效的'
, thenB
cannot be a tall array.
有关更多信息,请参阅Tall Arrays。
C/C++ Code Generation
使用MATLAB®CODER™生成C和C ++代码。
Thread-Based Environment
Run code in the background using MATLAB®背景池
或者accelerate code with Parallel Computing Toolbox™ThreadPool
。
This function fully supports thread-based environments. For more information, seeRun MATLAB Functions in Thread-Based Environment。
GPU Arrays
使用并行计算工具箱™在图形处理单元(GPU)上运行加速代码。
此功能完全支持GPU数组。金宝app有关更多信息,请参阅Run MATLAB Functions on a GPU(Parallel Computing Toolbox)。
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
此功能完全支持分布式数组。金宝app有关更多信息,请参阅运行具有分布式数组的MATLAB功能(Parallel Computing Toolbox)。
Version History
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
您还可以从以下列表中选择一个网站:
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.
Americas
- AméricaLatina(Español)
- Canada(English)
- United States(English)
欧洲
- Belgium(English)
- 丹麦(English)
- Deutschland(德意志)
- España(Español)
- Finland(English)
- 法国(Français)
- 爱尔兰(English)
- 意大利(Italiano)
- Luxembourg(English)
- Netherlands(English)
- 挪威(English)
- Österreich(德意志)
- Portugal(English)
- Sweden(English)
- 瑞士
- 英国(English)