bisection.m
来自「a m file for matlab the secant method」· M 代码 · 共 17 行
M
17 行
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 + =
减小字号Ctrl + -
显示快捷键?