Why does convolution shift on t axis?

3 次查看(过去 30 天)
I have two functions. I convolve them and get an output that is shifted to the left on the t axis. ex. clear all; clc t=linspace(-4,6,15645); x=0*t; ind = t>=0 & t<=1; x(ind)=2;
y=0*t; ind = t>=0 & t<=1; y(ind)=2*t(ind); ind = t>=1 & t<2; y(ind)=-2*(t(ind)-1)+2;
z=median(diff(t))*conv(x,y,'same');
plot(t,z,'r')
I have to add 1 to time to get the convolution correct... Someone point me in the right directions please

回答(1 个)

Image Analyst
Image Analyst 2016-9-25
Because the center of the moving window is to the left (or right) of the main signal when it first (or last) touches the tip of the main signal. use the 'same' option if you don't want the full convolution and want to chop off any values when the center of the moving window is not over the main signal.
  2 个评论
Jacob Pease
Jacob Pease 2016-9-25
both signals are equal to 0 at t<0. A true convolution of the two signals wouldn't give me values that are less than zero. Are you telling me that the convolution uses the center of one of the signals as t+0? That doesn't make sense.
Image Analyst
Image Analyst 2016-9-25
The reason is that you can't have negative indexes. So if a signal is 100 elements long and your filter window is 5 elements long, the right tip of your filter window will overlap the left tip of your signal when the filter window is shifted left and the center is at index -1. However there is no -1 index, or 0 index either, so the output array starts with element 1. Just look at any online discussion of how convolution works. Like here: https://www.tutorialspoint.com/dip/concept_of_convolution.htm

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by