Thread Subject: Calculating the volume under a non-gridded non-uniform surface

Subject: Calculating the volume under a non-gridded non-uniform surface

From: Brian Roberts

Date: 12 Aug, 2009 18:43:19

Message: 1 of 4

I have a dataset "A" (n by 3) of ordered triplets [x,y,z]. I want to calculate the volume between surface defined by "A" and the xy plane. "A" has only positive values but is not uniformly spaced and not gridded. "A" cannot be described by a simple function. Any help?

Subject: Calculating the volume under a non-gridded non-uniform surface

From: Doug Hull

Date: 12 Aug, 2009 19:13:20

Message: 2 of 4

Brian,

This is an excellent question. Without knowing all of your constraints, I can lay out a general plan. I will try to make this answer into a movie. See my other movies here: (http://blogs.mathworks.com/videos)

1.) Make a function (with interp2) that will give you the value at an arbitrary point See similar video about that:
http://blogs.mathworks.com/videos/2007/11/02/advanced-matlab-surface-plot-of-nonuniform-data/

2.) Use quad2d to do the integration.

I am working on this now, so will post more when finished.

Subject: Calculating the volume under a non-gridded non-uniform surface

From: Doug Hull

Date: 12 Aug, 2009 19:32:18

Message: 3 of 4

"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

Subject: Calculating the volume under a non-gridded non-uniform surface

From: Luigi Giaccari

Date: 14 Aug, 2009 17:27:19

Message: 4 of 4

It is even easier:

http://www.mathworks.com/matlabcentral/fileexchange/24593

http://www.mathworks.com/matlabcentral/fileexchange/23447

http://www.mathworks.com/matlabcentral/fileexchange/22185


http://www.advancedmcode.org/

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
quad Doug Hull 12 Aug, 2009 15:14:24
interp Doug Hull 12 Aug, 2009 15:14:24
integration Doug Hull 12 Aug, 2009 15:14:24
rssFeed for this Thread

Contact us at files@mathworks.com