Path: news.mathworks.com!not-for-mail
From: "Doug Hull" <hull@mathworks.SPAMPROOFcom>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Calculating the volume under a non-gridded non-uniform surface
Date: Wed, 12 Aug 2009 19:32:18 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 25
Message-ID: <h5v5c2$g3u$1@fred.mathworks.com>
References: <h5v2g7$8ba$1@fred.mathworks.com> <h5v48g$2ta$1@fred.mathworks.com>
Reply-To: "Doug Hull" <hull@mathworks.SPAMPROOFcom>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1250105538 16510 172.30.248.38 (12 Aug 2009 19:32:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 12 Aug 2009 19:32:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869436
Xref: news.mathworks.com comp.soft-sys.matlab:562821


"Doug Hull" <hull@mathworks.SPAMPROOFcom> wrote in message 
> I am working on this now, so will post more when finished.

I got it figured out:

%%%%%%%%%%%
n = 10;
randOffset = 0.1;
h = 1;

x = rand(n);
x(1:4) = [0 0 1 1]'; %force data points at corners so interpolation is valid in [0 1],[0 1]
y = rand(n);
y(1:4) = [0 1 0 1]';%force data points at corners so interpolation is valid in [0 1],[0 1]
z = h + randOffset*rand(n) - randOffset/2; %make average height


plot3(x,y,z,'.')
axis equal
zlim([0 h + randOffset])

interpZ = @(xi,yi) griddata(x,y,z,xi,yi) %set up interpolation

interpZ(0.5,0.5) %test interpolation
vol = quad2d(interpZ,0,1,0,1) %volume should be close to 1