问题描述:
刚学matlab菜鸟一枚,为什么书上的程序运行不了啊,求大神指教.
clear all;
a=0;
b=3*pi;
n=1000;h=(b-a)/n;
x=a;s=0;
f0=exp(-0.5*x)*sin(x+pi/6);
for i=1:n
x=x+h;
f1=exp(-0.5*x)*sin(x+pi/6);
s=s+(f0+f1)*h/2;
f0=f1;
end
s
clear all;
a=0;
b=3*pi;
n=1000;h=(b-a)/n;
x=a;s=0;
f0=exp(-0.5*x)*sin(x+pi/6);
for i=1:n
x=x+h;
f1=exp(-0.5*x)*sin(x+pi/6);
s=s+(f0+f1)*h/2;
f0=f1;
end
s
问题解答:
我来补答展开全文阅读