using conv to convolve two functions

4 次查看(过去 30 天)
kk
kk 2019-3-25
回答: kk 2019-3-27
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.

回答(1 个)

kk
kk 2019-3-27
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).

类别

Help CenterFile Exchange 中查找有关 Elementary Math 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by