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

10 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2021-1-24
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by