fu=function define in another function file.
function[bs]= bisection(fu, xl,xu,tol,n)
error=0;
t=0;while t <= n | error < tol
bs= xl+(xu-xl)/2;if(fu(xl)*fu(bs))<0
bs=xu;
elseif (fu(xu)*fu(bs))<0
bs=xl;else(feval(fu,xl)*feval(fu,bs))==0;break
end
error =(bs(t-1)-bs(t))/bs(t);if error < tol
break
end
t=t+1;
end
end
function f=fu(x)
x=0:10;
f=x.^3+4*x-10;
end
I would suggest that you define your functions in an another .m file, and add that .m file to your workbench. In Mathworks site: https://www.mathworks.com/help/techdoc/ref/function.html
Says that: "The function declaration must be the first executable line of any MATLAB function."