📄 bisection.m
字号:
function rtn=bisection(fx,xa,xb,n)
% Bisection Method
% The first parameter fx is a external function with respect to viable x.
% xa is the left point of the initial interval
% xb is the right point of the initial interval
% n is the number of iterations.
x=xa;fa=eval(fx);
x=xb;fb=eval(fx);
for i=1:n
xc=(xa+xb)/2;x=xc;fc=eval(fx);
X=[i,xa,xb,xc,fc];
disp(X),
if fc*fa<0
xb=xc;
else xa=xc;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -