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

6 ビュー (過去 30 日間)
Kaylee Chavez
Kaylee Chavez 2021 年 3 月 12 日
回答済み: Basil C. 2021 年 3 月 12 日
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 Center および File ExchangeCalculus についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by