I am trying to integrate a step function and I keep getting error messages.
Here is my code:
>> integral(step_fun,5,7)Error using step_fun (line 4)Not enough input arguments.
The step_fun is defined in a separate code file as:
function y = step_fun(x)y = 0; if x >= 0 y = 1;end;end
If I try:
func=@(t) step_fun(t)integral(func,5,7)
I got:
Error using integralCalc/finalInputChecks (line 515)Output of the function must be the same size as the input. If FUN is anarray-valued integrand, set the 'ArrayValued' option to true.Error in integralCalc/iterateScalarValued (line 315) finalInputChecks(x,fx);Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);Error in integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval);Error in integral (line 88)Q = integralCalc(fun,a,b,opstruct);
What does this mean? Thank you.
Best Answer