5_4.asv
来自「数值微分和数值积分:Newton-Cotes公式、复化公式和区间逐次半分法、外推」· ASV 代码 · 共 27 行
ASV
27 行
%%%%%%%% Double Integration by the Simpson's Rule %%%%%%%%
nx=input('Number of intervals in x_direction:');
ny=input('Number of intervals in y_direction:');
a=input('Lower limit of x,a?');
b=input('Lower limit of x,b?');
hx=(b-a)/nx;
x=[a:hx:b];
cy=c(x);
dy=d(x);
hy=(d(x)-c(x))/ny;
Result=0;
temp=0;
for i=1:nx
for j=1:ny
y=[c(j):hy:d(j)]
y=f(x(i),y)
temp=hy(j)/2*(2*sum(y)-f(x(i),c(j))-f(x(i),d(j)));
end
if i~=1&i~=nx temp=temp*2;end
Result=Result+temp;
end
Result=hx/2*Result
h=(b-a)/n;
x=[a:h:b];
y=f(x);
Result=h/2*
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?