Why different answers are coming during convolution of two functions using different number of data points ?

6 views (last 30 days)
I am trying to calculate convolution of two Gaussian function using 'conv' function in MATLAB.e.g.
h = @(x) gaussmf(x,[4,0]);
f = @(x) gaussmf(x,[3,0]);
x = -5:.1:5;
y = conv(h(x),f(x));
plot(y)
Now if in the second case if I use x = -5:0.05:5; here x-spacing is 0.05 instead of 0.1 as in the first case, so number of data points become twice. Convolution, y in the second case is coming twice to that of 1st case( i.e. peak hight is increasing twice). But this should not be the case. If we increase the number of points in a function to make it more smoother it should not affect the convolution results. Thanks

Accepted Answer

Image Analyst
Image Analyst on 9 Jan 2015
Who told you this incorrect statement: "If we increase the number of points in a function to make it more smoother it should not affect the convolution results."? The length of the convolution is the length of the two arrays you convolve summed together. So if you double the number of elements in x, then y will have double the number of elements, just as you observed. And the peak value will be about twice as high because you're multiplying and summing twice as many elements as before.
  4 Comments
Debdas
Debdas on 7 Apr 2015
Ok I got the answer. So you want to say that I have to scale the output to get the same peak hight. As convolution is basically: do the ffts of two array an then multiply both ffts and then do inverse fft of that arrays. Even if i want to change the number of elements of a function at the end I just had to scale with output with dt(sampling interval). So this will not affect the output. Also I found some useful answer on the following link.
Thanks a lot

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!