How to perform surface integral using an interpolation function?

11 次查看(过去 30 天)
I have an interpolation function generated with "interp2":
G=@(x,y)interp2(xData,yData,zData,x,y);
when I try to integrate such function with "integral2" I either get some warning about failing to converge, or the computation time becomes extremely large. As an example:
A = integral2(G,xmin,xmax,ymin,ymax,'RelTol',1e-10,'AbsTol',1e-10,'method', 'auto');
Warning: Reached the maximum number of function evaluations (10000). The
result fails the global error test.
> In funfun\private\integral2Calc>integral2t at 130
In funfun\private\integral2Calc at 10
In integral2 at 106

采纳的回答

MathWorks Support Team
The main reason behind this behaviour is that you are trying ot use a general purpose integrator on a function which is not smooth enough to benefit from the high order integration methods used. The lack of smoothness between each piece forces the integrator to go to great expense. Because the newer integration functions (like "integral2") are much more conservative and reliable than the old ones, the expense may be great indeed.
The best (and by far more efficient) way to integrate over an interpolated function is to split between the various pieces, in fact the integral is extremely difficult to integrate at the borders of each piece , while the piece itself is very easy to integrate. You can then iterate through the pieces and add up all the contributions.
As an example:
A2 = 0;
for ix = 1:N-1
xleft = xData(ix);
xright = xData(ix+1);
for iy = 1:N-1
yleft = yData(iy);
yright = yData(iy+1);
A2 = A2 + integral2(G,xleft,xright,yleft,yright,'RelTol',1e-10,'AbsTol',1e-10,'method', 'auto');
end
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

尚未输入任何标签。

产品


版本

R2013b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by