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

6 vues (au cours des 30 derniers jours)
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);

Réponse acceptée

Basil C.
Basil C. le 12 Mar 2021
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)

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by