tongqingliu

保持学习的态度

MATLAB二分法函数求根

 

function xc = bisect(f,a,b,tol)

ind = b-a;
while ind > tol
    xx = (a+b)/2;
    if f(a)*f(xx) < 0
        b = xx;
    else
        a = xx;
    end
    ind = b - a;
end
xc = xx;

 

posted on 2017-02-24 13:31  tongqingliu  阅读(6204)  评论(0编辑  收藏  举报

导航