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!