I am getting error in integrating a function from 0 to infinity wrt x. Kindly help.

CODE:
fun=@(x) (p*q*r*exp(-x*d/sqrt(a*b)));
rx=integral(fun,0,Inf)
Msq=pi*u*sqrt(a*b)*rx
% where variables p, q, r, d, a and b are defined
ERROR:
Error using *
Inner matrix dimensions must agree.
Error in @(x)(p*q*r*exp(-x*d/sqrt(a*b)))
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 83)
[q,errbnd] = vadapt(@AToInfInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in SaadMutashar (line 83)
rx=integral(fun,0,Inf)

3 Comments

put dots in front of arithmetic operators like .* ./ , by the what are the sizes of the variables?
What is p, q, r, d, a and b? Please attach mat-file with your variables.

Sign in to comment.

 Accepted Answer

Try
q = integral(fun,0,Inf,'ArrayValued',1);
but in your case the result is a zero vector, due to value of the gamma = 0.

1 Comment

Sir, I used the below code and am able to clear the error.
syms x
q=int(fun,x,0,Inf).
Yes its 0 vector due to gamma=0. I think I have to change the gamma value now. Thank you sir for your answer.

Sign in to comment.

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Asked:

on 24 Jan 2019

Commented:

on 24 Jan 2019

Community Treasure Hunt

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

Start Hunting!