问题描述:
MATLAB 最小二分法
下面是我写的程序.但是一直ERROR.
他好像提示是 fuction is not defined
function f=fun(x)
f=x-tan(x)
e = input('精度要求 e = ');
a = input('有根区间[a,b]取 a=');
b = input('有根区间[a,b]取 b=');
x1=(a+b)/2;
s = b-a;
while
s >= e;
x1=(a+b)/2;
y=fun(x1);
if y*fun(a)>0
a=x1;
b=b;
s=b-a;
elseif y*fun(a)
下面是我写的程序.但是一直ERROR.
他好像提示是 fuction is not defined
function f=fun(x)
f=x-tan(x)
e = input('精度要求 e = ');
a = input('有根区间[a,b]取 a=');
b = input('有根区间[a,b]取 b=');
x1=(a+b)/2;
s = b-a;
while
s >= e;
x1=(a+b)/2;
y=fun(x1);
if y*fun(a)>0
a=x1;
b=b;
s=b-a;
elseif y*fun(a)
问题解答:
我来补答展开全文阅读