Integral not calculating. Too many input requirements and error using function.
7 次查看(过去 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);
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!