Calculating triple integral between two surfaces gained with TriScatteredInterp or griddata
2 views (last 30 days)
Show older comments
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
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
Accepted Answer
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)
0 Comments
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!