Reputation: 181
I need to evaluate the following integral in MATLAB (numerically):
I already tried various things but I can't figure out how to solve this! Following is my last try:
Fdx = @(x) integral(@(y)1./(1+sqrt(y.^2))*(1-pi^2),0,x);
dFdx(1)
F = 8 * integral(dFdx,0,10)
As a result MATLAB gives me this error message:
Error using integral (line 85) A and B must be floating-point scalars.
Error in @(x)integral(@(y)1./(1+sqrt(y.^2))*(1-pi^2),0,x)
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);
Error in test (line 7) F=8 * integral(dFdx,0,10)
Upvotes: 0
Views: 423
Reputation: 380
Try using integral2
instead. See example 2 in the documentation:
http://www.mathworks.com/help/matlab/ref/integral2.html
Hope it helps.
Upvotes: 2