I am trying to use the integral function in MatLab, but I get the following error depending on the anonymous function I use.
f = @(x) x;integral(f, 1, 2) % WORKS %
ans = 1.5
% Change function
f = @(x) 1;integral(f, 1, 2) % ERROR %
Error using integralCalc/finalInputChecks (line 526)
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.
What is this error, and why is it sensitive to the function I use?
Best Answer