Integral not calculating. Too many input requirements and error using function.

조회 수: 8 (최근 30일)
Hi there. I am just trying to take the integral of a simple function in MATLAB and it is not calculating. I was messing with it for awhile and I went from too many input arguments to not enough input arguments. I am sure it is a simple solution, but I cannot seem to figure it out.
>> syms Z
>> E = @(Z) Z.^2.+9.
E =
function_handle with value:
@(Z)Z.^2. +9.
>> I = integral2(E, 0, 2, 0, 2*pi)
Error using @(Z)Z.^2. +9.
Too many input arguments.
Error in integral2Calc>integral2t/tensor (line
228)
Z = FUN(X,Y); NFE = NFE + 1;
Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in integral2Calc (line 9)
[q,errbnd] =
integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral2 (line 106)
Q =
integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);

채택된 답변

Basil C.
Basil C. 2021년 3월 12일
The error occurs from the fact you are performing a double integration but are passing only one variable so MATLAB doesnt know which limit applied to which variable. Rather try using this:
E = @(x,y) x.^2+9
or
E = @(x,y) y.^2+9
depending on your application and then perform the double integration
I = integral2(E, 0, 2, 0, 2*pi)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by