Infintite Loop- bisection search how to stop
1 次查看(过去 30 天)
显示 更早的评论
function rootx = bisectionSearch (fhandle,a,b,epsilon)
while (b-a) > epsilon %assume a<b
m =(b+a)/2
fhandlem=fhandle(m);
if fhandlem == 0
rootx = m %If f(m) is equal to zero then return the root as m
else if sign (fhandle(m))== sign (fhandle(a)) %
a=m; % If f(m) has the same sign as f(a) Replace a with m
else
m=b;
end
end
end
m;
end
Hi guys this is an infinte loop and I do not know why or how to fix it Please help if possible. when I test it it keeps giving me m values repeatly of 1.75 and I dont think thats even the right answer. please Help!
2 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!