How to Integrate Lognormal PDF multiplied by a function.

1 view (last 30 days)
Hi,
I am trying to ∫ D(V)*F(V)dV eq1
min=_(0.8e-26) and max=(1.35e-26)
D(t,V)=2*Ps*(1-exp(-(t)./(Vo*exp((Ps*10000000-Wb)*V/(Kb*300))))) and F(V)= Lognormal PDF=(1./(V.*sigma.*sqrt(2.*pi)).*exp(-log(V)-mu).^2/(2.*sigma^2)).*V
Find below, the code I wrote to compute the integral of eq1:
Dp=@(V)(1./(V.*sigma.*sqrt(2.*pi)).*exp(-log(V)-mu).^2/(2.*sigma^2)).*V.*2*Ps*(1-exp(-(t)./(Vo*exp((Ps*10000000-Wb)*V/(Kb*300)))))
Dp =
function_handle with value:
@(V)(1./(V.*sigma.*sqrt(2.*pi)).*exp(-log(V)-mu).^2/(2.*sigma^2)).*V.*2*Ps*(1-exp(-(t)./(Vo*exp((Ps*10000000-Wb)*V/(Kb*300)))))
>> integral(Dp,0.8e-26,1.35e-26)
Error message I got were:
Matrix dimensions must agree.
Error in
@(V)(1./(V.*sigma.*sqrt(2.*pi)).*exp(-log(V)-mu).^2/(2.*sigma^2)).*V.*2*Ps*(1-exp(-(t)./(Vo*exp((Ps*10000000-Wb)*V/(Kb*300)))))
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Please can anyone kindly assist me or advice me?
Thank you
  4 Comments
Mudaga Andrew Nomuoja
Mudaga Andrew Nomuoja on 5 Apr 2020
Thanks Tommy, here we go:
Kb=1.38e-23;Ps=0.74;Wb=1.44e-19;Vo=1.00e-13:V=1.00e-26: sigma=0.05:Mu=0;

Sign in to comment.

Accepted Answer

Tommy
Tommy on 6 Apr 2020
The error (Matrix dimensions must agree) occurs because your t is an array of length 3503185 and the V passed into Dp() by integral() is an array of length 150. Therefore, the following portion of Dp() throws the error:
>> -(t)./(Vo*exp((Ps*10000000-Wb)*V/(Kb*300)))
Matrix dimensions must agree.
You can find the integral of Dp() over your range of V by specifying a scalar value for t. If you want to see how the integral varies over a range of log(t), then you can evaluate the integral at each value of t independently and combine the results:
Kb=1.38e-23;Ps=0.74;Wb=1.44e-19;Vo=1.00e-13;V=1.00e-26;sigma=0.05;mu=0;
t=logspace(log10(0.00000226),log10(55),5000);
Dp=@(V,t)(1./(V.*sigma.*sqrt(2.*pi)).*exp(-log(V)-mu).^2/(2.*sigma^2)).*V.*2*Ps.*(1-exp(-(t)./(Vo*exp((Ps*10000000-Wb)*V/(Kb*300)))));
y = arrayfun(@(t) integral(@(V) Dp(V, t), 0.8e-26, 1.35e-26), t);
plot(log(t), y);
I decreased the length of t considerably because it would take a very long time to evaluate the integral 3503185 different times, and I changed t from a linearly-spaced vector to one spaced logarithmically.
  2 Comments
Mudaga Andrew Nomuoja
Mudaga Andrew Nomuoja on 7 Apr 2020
Thanks Tommy, I will run the code and let you the outcome. I am immensely grateful for your feedback!!!
Mudaga Andrew Nomuoja
Mudaga Andrew Nomuoja on 7 Apr 2020
The code worked fine and generated a graph for further analysis. I most grateful.

Sign in to comment.

More Answers (1)

Mudaga Andrew Nomuoja
Mudaga Andrew Nomuoja on 5 Apr 2020
Hi Tommy,
t=0.00000226:0.0000157:55;x=log(t);
I was hoping to plot the integral Dp as a function of log(t). Hence I used the above parameter.

Community Treasure Hunt

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

Start Hunting!