When using the INTEGRAL command as follows,
integral(@(x) x^2,0,100)
I receive an error:
Error using ^ Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead. Error in @(x)x^2 Error in integralCalc/iterateScalarValued (line 314) fx = FUN(t); Error in integralCalc/vadapt (line 133) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen); Error in integralCalc (line 76) [q,errbnd] = vadapt(@AtoBInvTransform,interval); Error in integral (line 89) Q = integralCalc(fun,a,b,opstruct);
This issue also occurs when I multiply "x" in functions such as "x*sin(x)". Additionally, I get another type of error when using divisions:
integral(@(x) x/exp(x),0,100)
Error using integralCalc/finalInputChecks (line 515) Output of the function must be the same size as the input. If FUN is an array-valued integrand, set the 'ArrayValued' option to true. Error in integralCalc/iterateScalarValued (line 315) finalInputChecks(x,fx); Error in integralCalc/vadapt (line 133) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen); Error in integralCalc (line 76) [q,errbnd] = vadapt(@AtoBInvTransform,interval); Error in integral (line 89) Q = integralCalc(fun,a,b,opstruct);
Best Answer