在 MATLAB 中通过双重求和来近似二重积分

问题描述 投票:0回答:1

我正在尝试使用 MATLAB 通过使用双和的概念来数值近似二重积分。假设我尝试集成的函数位于 x 和 y 上,我可以执行以下操作吗,

result=0;
for i=1:0.1:x
for j=1:0.1:y
fun(i,j)= x(i).*y(j)*0.1^2; %the function I want to integrate times the increment
result = result + fun(i,j);
end
end

还有人知道最接近积分的最佳增量是多少吗? 我很感激任何建议!

matlab numerical-integration
1个回答
0
投票

数值积分是一个相当复杂的课题。也许,最好的标准选项是使用(http://www.mathworks.nl/help/matlab/ref/integral2.html#btdgcqq

result = integral2(fun,xmin,xmax,ymin,ymax)

如果您对一般数值积分感兴趣,请查看 Wiki (http://en.wikipedia.org/wiki/Numerical_integration)。对于具体的实现,Numerical Recipes 是一个很好的参考点(http://www.it.uom.gr/teaching/linearalgebra/NumericalRecipiesInC/,抱歉,那里没有 Matlab 版本)

© www.soinside.com 2019 - 2024. All rights reserved.