how world i find the lowest root with bisection
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
rantunes
el 3 de Mzo. de 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 comentarios
Ver también
Categorías
Más información sobre Performance and Memory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!