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

2 views (last 30 days)
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

Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 24 Jan 2019
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
Swathi S
Swathi S on 24 Jan 2019
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.

More Answers (1)

Torsten
Torsten on 24 Jan 2019
q=integral(fun,0,Inf,'ArrayValued',true)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!