using conv to convolve two functions

15 views (last 30 days)
kk
kk on 25 Mar 2019
Answered: kk on 27 Mar 2019
Hello,
I need to compute a convolution of a Gaussian (with unit area) and a stretched-exponential (SE) . For , this function simplifies to an exponential, for which I have an analytical formula describing the convolution.
To compute the convolution, I use this code:
function y = GaussSEConv(t,w,x0,tau,beta)
%%
Girf=Gaussian(t,1,x0,w); % Gaussian with area = 1
f=StretchedExponential(t,tau,0,beta); % stretched exponential without any amplitude, i.e. with A=1
dx=(t(2)-t(1))/2;
x0=x0+dx; % shift x0 by half the interval in x to match the analytical formula
y=conv(f,Girf,'full');
y(length(t)+1:end)=[]; % crop y to have the same axis
end
For , I can compare the output of this function with the result of the analytical formula. The shape of the function given by the convolution code is identical to the ouput of the analytical formula, but I have a problem with the amplitude of the resulting convolution. Using the analytical formula, I get what I would expect from a convolution. For typical data
t=(0:2:400)'; w=6; x0=50; tau=30; beta=1;
and the analytical formula I get
trapz(t,y)=29.9997
which should be the integral of the convolution of the two functions (1*tau=tau).
Using the above convolution code produces
trapz(t,y)=15.5054
The difference between the code and the analytical formula depends on the chosen axis t, coefficient τ and probably also on the coefficient β (difficult to test).
What factor am I missing?
I forgot to mention that .
Thanks.

Answers (1)

kk
kk on 27 Mar 2019
I have figured this out myself, I just need to multiply y with the interval of an element in the x axis t(2)-t(1).

Community Treasure Hunt

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

Start Hunting!

Translated by