how world i find the lowest root with bisection
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
rantunes
am 3 Mär. 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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Performance and Memory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!