我在这里有两个功能:
function y=f(x)
y=(x*%e^x)-cos(x);
endfunction
function c=regulafalsi(f, x0, x1, tol)
i=1;
n(1)=100;
if f(x0)*f(x1) < 0
a(1)=x0;
b(1)=x1;
c(1)=a(1)-f(a(1))*(b(1)-a(1))/(f(b(1))-f(a(1)));
printf('i.\t\t a\t\t c\t\t b\t\t f(c)\t Galat \n');
printf('%2d \t %11.4f \t %11.4f \t %11.4f \t %11.4f \n',i,a(i),c(i),b(i),f(c(i)));
while abs(n(i))>=tol,
if f(a(i))*f(c(i))< 0
a(i+1)=a(i);
b(i+1)=c(i);
end
if f(a(i))*f(c(i))> 0
a(i+1)=c(i);
b(i+1)=b(i);
end
c(i+1)=a(i+1)-f(a(i+1))*(b(i+1)-a(i+1))/(f(b(i+1))-f(a(i+1)));
n(i+1)=abs((c(i+1)-c(i))/(c(i+1)));
printf('%2d \t %11.4f \t %11.4f \t %11.4f \t %11.4f \t %7.4f \n',i+1,a(i+1),c(i+1),b(i+1),f(c(i+1)),n(i+1));
i=i+1;
end
else
printf(' ');
end
endfunction
如何绘制这些功能? 我试过情节(y,c)不工作。