function[root,ea,iter]=bisectt(func,xl,xu,es,maxit,varargin)if nargin <3, disp('error')end test=func(xl,varargin{:})*func(xu,varargin{:}); if test>0, disp('error') endif test>0,error('no sign change'),endif nargin<4|isempty(es), es=0.0001;endif nargin<5|isempty(maxit), maxit=50;enditer = 0; xr = xl; ea = 10;while (1)xrold = xr;xr = (xl + xu)/2;iter = iter + 1;if xr ~= 0,ea = abs((xr - xrold)/xr) * 100;endtest = func(xl,varargin{:})*func(xr,varargin{:});if test < 0xu = xr;elseif test > 0xl = xr;elseea = 0;endif ea <= es | iter >= maxit,break,endendroot = xr;
I need to create another function file to calculate f(xl), f(xr), f(xu) how can i do that? the function is:
sqrt((9.81*x)/0.25)*tanh(sqrt((9.81*0.25)/x)*4)
thanks for your help!
Best Answer