how world i find the lowest root with bisection

1 view (last 30 days)
function [xr ea iter] = bisect(func, x1, xu, es, maxit)
% function [xr ea iter] = bisect(func, x1, xu, es, maxit)
% bisection method
if func(x1)*func(xu)>=0, error('no sign change'); end
xold = x1;
for iter = 1:maxit
xr = (xL+xU)
xr2 = roots([1 0 -3 -1]);
test = func(xL)*func(xr);
ea = abs((xr-xold)/xr)*100;
if test<0,xU = xr;
elseif test>0, xL = xr;
else ea = 0;
end
if ea<=es, break; end
xold = xr;
end
end

Answers (1)

rantunes
rantunes on 3 Mar 2015
Hey,
You have to be more specific. I suspect your code doesn't even run due to non-coherent syntax.
What do you want to do? Compute the root of a function using the bisection method?
Greets

Categories

Find more on Testing Frameworks in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!