function SimpsonIt
a=input('input the left point a:');
b=input('input the right pointb:');
n=input('input the number of the equal disparting n:');
h=(b-a)/n;
x=a+h/2:h:b-h/2;
disp('input the function f(x):');
y=input('y=','s');
t=eval(y);
s=4*sum(t);
x=a:h:b;
t=eval(y);
s=s+2*sum(t)-t(1)-t(n+1);
s=h*s/6;
fprintf(1,'the result is:%4.4f',s);
这是辛普森算法的代码段,我用这个方法想要计算这个函数:
但是运行的输出结果是这个:
请教。