MATLAB Answers

how to find volume using integral

159 views (last 30 days)
sharon on 6 Jan 2015
Edited: Mike Hosea on 14 Feb 2015
how to calculate volume using integral function from the given matrix of a,b,c coordinates

Answers (1)

Mike Hosea
Mike Hosea on 14 Feb 2015
Edited: Mike Hosea on 14 Feb 2015
You can't do that with INTEGRAL. The integral functions are for integrating functions, not data. A set of coordinates in 3-D space does not have a volume, since points have no volume. I would guess that you mean, for example, the volume of a polyhedron defined by those vertices or some such. That's just a guess. If that is what you mean, you might want to ask "How do I find the volume of a polyhedron in MATLAB given a matrix of vertex points?"
Now to answer the question of the title of how to find volume using INTEGRAL, here is an example that computes the volume of a sphere. Of course it's fairly dumb to compute the area of a sphere this way, but the point of the example is to illustrate the use of functions to define the region of interest. It should be clear how to modify it for other regions that can be described as being bounded by a <= x <= b, c(x) <= y <= d(x), e(x,y) <= z <= f(x,y).
a = -1;
b = 1;
c = @(x)-sqrt(1 - x.^2);
d = @(x)sqrt(1 - x.^2);
e = @(x,y)-sqrt(1 - x.^2 - y.^2);
f = @(x,y)sqrt(1 - x.^2 - y.^2);
volume = integral3(@(x,y,z)ones(size(x)),a,b,c,d,e,f)


Community Treasure Hunt

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

Start Hunting!