conv()函数是用于计算向量的卷积和多项式乘法。
使用说明:
w=conv(u,v)
u,v为向量,其长度可以不相同。
实例1:多项式乘法,(s^2+2s+2)(s+4)(s+1)
w=conv([1,2,2],conv([1,4],[1,1]))
w =1 7 16 18 8
P=poly2str(w,'s')
P =s^4 + 7 s^3 + 16 s^2 + 18 s + 8
注意:在MATLAB中,可以用函数y=conv(x,h)计算卷积。
y=conv(x,h)是用来实现卷级的,对x序列和h序列进行卷积,输出的结果个数等于x的长度与h的长度之和减去1。
卷积公式:z(n)=x(n)*y(n)= ∫x(m)y(n-m)dm.
程序:以下两个程序的结果一样
(1)h = [3 2 1 -2 1 0 -4 0 3]; % impulse response
x = [1 -2 3 -4 3 2 1]; % input sequence
y = conv(h,x);
n = 0:14;
subplot(2,1,1);
stem(n,y);
xlabel('Time index n'); ylabel('Amplitude');
title('Output Obtained by Convolution'); grid;
(2)x1 = [x zeros(1,8)];
y1 = filter(h,1,x1);
subplot(2,1,2);
stem(n,y1);
xlabel('Time index n'); ylabel('Amplitude');
title('Output Generated by Filtering'); grid;
参考资料:百度百科-MATLAB