how world i find the lowest root with bisection

조회 수: 1 (최근 30일)
adriana resendez
adriana resendez 2015년 3월 3일
답변: rantunes 2015년 3월 3일
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

답변 (1개)

rantunes
rantunes 2015년 3월 3일
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

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by