当序列不是从0开始,必须对conv函数稍加扩展,计算卷积及y(n)的位置向量ny,下面是编写计算这种卷积的通用卷积函数
h=ones(1,5);nh=-2:2;
x=ones(1,5);nx=-2:2;
nys=nh(1)+nx(1);
nyf=nh(end)+nx(end);
y=conv(h,x);
ny=nys:nyf;
subplot(221);
stem(y,'.');title('y');
subplot(222);
stem(ny,'.');title('ny');