MATLAB: Integral2 error message Error using integral2 (line 71) XMIN must be a floating point scalar.

.

Create the anonymous function.
fun = @(x,y) 4+(y./25)-(x.^2)./50;
Integrate and to q1, Integrate and to q2
q1 = integral2(fun,-1,1,-1,0)
xmin = @(y) -sqrt(1-y.^2);
xmax = @(y) sqrt(1-y.^2);
q2 = integral2(fun,xmin,xmax,0,1)
Error using integral2 (line 71)
XMIN must be a floating point scalar.
final =q1+q2
anyone can help in this error?

Best Answer

When you use integral2(), the first two time bounds must be scalar floating point constants. The second two time bounds can be either scalar floating point or else function handle.
You are using function handles for your first two time bounds. You need to reverse the order of integration.
xmin = @(y) -sqrt(1-y.^2);
xmax = @(y) sqrt(1-y.^2);
q2 = integral2(@(Y,X)fun(X,Y),0,1,xmin,xmax)