📄 bisection.m
字号:
function root=bisection(xl,xu,maxit)
%Uses bisection method to find the root of the function sent to it in the
%given interval with fixed number of iterations (maxit).
%x1,xu=lower and upper limits of the interval
%output:root
es=0.0001;
iter=0;
xr=xl;
falpha1 = findroot(xl);
falpha2 = findroot(xu);
if (falpha1 * falpha2) < 0
while (xu - xl) > es
xmid = (xl + xu)/2;
falpha3 = findroot(xmid);
if (falpha1 * falpha3) > 0
xl = xmid;
falpha1 = falpha3;
else
xu = xmid;
falpha2 = falpha3;
end
end
root = xmid;
fprintf('Alpha = %8.6f', root)
return
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -