Why convolution of two functions changes with changing the range of x axis ?
35 次查看(过去 30 天)
显示 更早的评论
Dear friends,
Could anyone kindly help me regrading a confusion during finding convolution of two functions.
I am trying to calculate convolution of two Gaussian function using 'conv' function in MATLAB.e.g.
f = @(x) gaussmf(x,[0.4,0]);
h = @(x) gaussmf(x,[0.8,0]);
Now if I consider three different cases with different xrange
(I) x = -4:.01:4;
y1 = conv(h(x),f(x));
xp=-8:0.01:8
plot(xp,y1)
(II) x=-1:0.01:4;
y2= conv(h(x),f(x));
xp=-2:0.01:8
plot(xp,y2)
(III) x=0:0.01:4;
y3=conv(f(x),h(x))
xp=0:0.01:8
plot(xp,y3)
Don't you think these above three plots (y1,y2,y3 vs x) should lay on top of each other except the starting point of the plots will be different. I expected something like this
Because the convolution of two Gaussians is another Gaussian and we can calculate the convolution numerically very easily. I have calculated the convolution numerically an got the above ans.
But in MATLAB using conv function I am getting different ans
My question is why changing the xrange of two function changing the convolution results although according to theory, convolution function will not change. As my knowledge in this field is limited and may be I am conceptually wrong.
Any help will be highly appreciated.
Thanks
Deb
0 个评论
回答(2 个)
Image Analyst
2015-4-8
Why do you think there won't be more elements when you convolve? The output length will be the sum of the two signal lengths because they just start overlapping when the right tail of the sliding function overlaps the left tail of the "still" function, and then they don't stop overlapping until the left tail of the sliding function just barely overlaps the right tail of the "still" function. Now if you look at where the left element of the sliding function is when those events happen, you'll realize that the left element (and of course all the elements) of the sliding signal moves twice as far.
Stephen23
2015-4-8
编辑:Stephen23
2015-4-8
shape — Subsection of convolution 'full' (default) | 'same' | 'valid'
Subsection of the convolution, specified as 'full', 'same', or 'valid'.
- 'full' Full convolution (default).
- 'same' Central part of the convolution of the same size as u.
- 'valid' Only those parts of the convolution that are computed without the zero-padded edges. Using this option, length(w) is max(length(u)-length(v)+1,0), except when length(v) is zero. If length(v) = 0, then length(w) = length(u).
3 个评论
Stephen23
2015-4-8
"This means the nature of the function obtained after convolution will change depending on x-range": yes indeed, and this appears to be the confusion here. Numerical convolution is not the same as a "mathematical" or function convolution. For a start it is not possible to perform it from -Inf to +Inf, and selecting the endpoints will make a big difference to the output.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!