Calculating triple integral between two surfaces gained with TriScatteredInterp or griddata

2 views (last 30 days)
I am trying to calculate a triple integral of a function over a body defined as an intersection of two surfaces which I get interpolating data points using TriScatteredInterp or griddata, so they are functions z1(x,y) and z2(x,y). Actually, it is a calculation of the gravitational potential of a homogenous body of completely irregular shape at a point outside of it. The problem is in defining integral limits. Integration over a thetraedron is completed with no problems at all, but as I try to use my functions as lower and upper limits I always encounter errors.
Could you help me, please?
Thank you. Ivan
  1 Comment
Kiran
Kiran on 30 Dec 2014
Hello,
seems like the nit.zip has been deleted from the website. Will you please send me the same which I need urgently.
Thanks

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 6 Sep 2011
Rather than trying to code the integration limits as functions, could you instead integrate over fixed intervals, but include a term in the integrand that makes it zero when it lies outside the desired limits?
In response to your answers (which would have been better positioned as comments on my answer), I have included the following code. It calculates the volume of a cube (of side length 2) and a sphere (of diameter 2). The sphere calculation uses the method I suggested, and seems to work fine.
% Volume of cube
f1 = @(x,y,z) ones(size(x))
Q1 = triplequad(f1,-1,1,-1,1,-1,1)
% Volume of sphere
f2 = @(x,y,z) ones(size(x)) .* (x.^2+y.^2+z.^2)<1
Q2 = triplequad(f2,-1,1,-1,1,-1,1)

More Answers (2)

Ivan
Ivan on 7 Sep 2011
Thank you very much, works. Actually I tried that yesterday, but obviously I had made some mistakes in defining function. Also I'm using function numint3 from nit.zip from the following link: http://www-users.math.umd.edu/users/jmr/241/mfiles/ which is described here: http://www-users.math.umd.edu/~jmr/241/tripleint.html and it works very well.
  1 Comment
Kiran
Kiran on 30 Dec 2014
Hello,
seems like the nit.zip has been deleted from the website. Will you please send me the same which I need urgently.
Thanks

Sign in to comment.


Ivan
Ivan on 7 Sep 2011
Actually it still doesn't work. Using numint3 I do get a result which is always the same, independantly of the integrand. Triplequad returns an error. Any other ideas?

Community Treasure Hunt

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

Start Hunting!