当前位置: 代码迷 >> 综合 >> 【 MATLAB 】conv 函数介绍(卷积和多项式乘法)
  详细解决方案

【 MATLAB 】conv 函数介绍(卷积和多项式乘法)

热度:83   发布时间:2023-12-12 22:02:18.0

conv

Convolution and polynomial multiplication

Syntax

w = conv(u,v)

w = conv(u,v,shape)

Description

w = conv(u,v)返回向量u和v的卷积。如果u和v是多项式系数的向量,则对它们进行卷积相当于将两个多项式相乘。

 

w = conv(u,v,shape) returns a subsection of the convolution, as specified by shape. For example, conv(u,v,'same') returns only the central part of the convolution, the same size as u, and conv(u,v,'valid') returns only the part of the convolution computed without the zero-padded edges.

w = conv(u,v,shape)返回卷积的子部分,由形状指定。
例如,conv(u,v,'same')仅返回卷积的中心部分,与u的大小相同,而conv(u,v,'valid')仅返回计算后的卷积部分而没有零填充边。


Polynomial Multiplication via Convolution

 

Create vectors u and v containing the coefficients of the polynomials x^2 + 1 and 2x + 7.

u = [1 0 1];
v = [2 7];

Use convolution to multiply the polynomials.

w = conv(u,v)
w = 1×42     7     2     7

w contains the polynomial coefficients for  2x^3 + 7x^2 + 2x + 7.


Vector Convolution

Create two vectors and convolve them.

u = [1 1 1];
v = [1 1 0 0 0 1 1];
w = conv(u,v)
w = 1×91     2     2     1     0     1     2     2     1

The length of w is length(u)+length(v)-1, which in this example is 9.


Central Part of Convolution

Create two vectors. Find the central part of the convolution of u and v that is the same size as u.

u = [-1 2 3 -2 0 1 2];
v = [2 4 -1 1];
w = conv(u,v,'same')
w = 1×715     5    -9     7     6     7    -1

w has a length of 7. The full convolution would be of length length(u)+length(v)-1, which in this example would be 10.



 

 

 

 

 

  相关解决方案