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
0 个评论
回答(1 个)
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 个评论
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!