运行下面简单的程序,二分法求方程的根,调试的时候在循环处设断点,继续系统就退出了,直接运行没有问题
clc;clear all
f=@(x)sin(x);
a=-1;
b=pi/2;
e=1e-8;
k=100;
a0=a;
b0=b;
x=(a0+b0)/2.0;
fa = f(a);
fb = f(b);
fx=f(x);
while(abs(fx) > eps)
if (sign(fx)*sign(fa) < 0)
b0 = x;
fb = fx;
else
a0 = x;
fa = fx;
end
x = (a0+b0)/2.0;
fx=f(x);
end