# Calculate volume encapsuled by two surfaces

4 views (last 30 days)
Maron Dolling on 21 Mar 2022
Commented: Maron Dolling on 22 Mar 2022
Hey guys,
I have following problem: I need to calculate the volume that is encapsuled by two surfaces (see pic). I can sample the surface points since it is represented as an sfit.
I tried to use integral2 like this:
fun1 = @(x,y) my_blue_fit(x,y);
fun2 = @(x,y) my_red_fit(x,y);
vol1 = integral2(fun1, -4, 4, -4, 4);
vol2 = integral2(fin2, -4, 4, -4, 4):
vol_total = vol1 - vol2;
However, this is obviously not correct since I only want the encapsuled volume, and not the integral across the whole FOV.
Can anyone help me to get the integral borders right? Thanks in advance!
(P.s.: The volume has an irregular shape, so it doesn't have a circular footprint or smth like that)

Torsten on 22 Mar 2022
Edited: Torsten on 22 Mar 2022
fun = @(x,y) max(fun1(x,y)-fun2(x,y),0);
vol = integral2(fun,-4,4,-4,4)
##### 1 CommentShowHide None
Maron Dolling on 22 Mar 2022
Thanks!

### Categories

Find more on 3-D Volumetric Image Processing in Help Center and File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!