MATLAB的编程问题

来源:百度知道 编辑:UC知道 时间:2024/05/07 10:06:32
a=a;b=b;n=1000;h=(b-a)/n;
x=a:h:b;y=0;
f=(x+1)./(x^3-1);
for i=1:n
s(i)=(f(i)+f(i+1))*h/2;
y=y+s(i);
end
y

a=3;b=5;n=1000;h=(b-a)/n;
x=a:h:b;y=0;
f=(x+1)./(x.^3-1);
for i=1:n
s(i)=(f(i)+f(i+1))*h/2;
y=y+s(i);
end
y



syms x a b
f=(x+1)/(x^3-1);
int(f,a,b)

a=2;b=3;
n=1000;
h=(b-a)/n;
x=a:h:b;
y=0;

z=1;
for x=a:h:b
s(z)=((x+1)/(x^3-1)+(x+h+1)/((x+h+1)^3-1))*h/2;
y=y+s(z);
z=z+1;
end
y