# How to calculate volume of surf plot (3d plot) en matlab?

57 views (last 30 days)
abdelmadjid benrabah on 17 Sep 2021
Commented: Star Strider on 17 Sep 2021
How to calculate volume of surf plot (3d plot) en matlab?
using variable x and y and function z

Star Strider on 17 Sep 2021
The surf plot arguments are matrices, so use trapz:
x = 1:10;
y = 1:20;
[X,Y] = meshgrid(x,y);
z = exp(-((X-5)/5.*(Y-10)/10).^2)
z = 20×10
0.5955 0.7471 0.8784 0.9681 1.0000 0.9681 0.8784 0.7471 0.5955 0.4449 0.6639 0.7942 0.9027 0.9747 1.0000 0.9747 0.9027 0.7942 0.6639 0.5273 0.7308 0.8383 0.9246 0.9806 1.0000 0.9806 0.9246 0.8383 0.7308 0.6126 0.7942 0.8784 0.9440 0.9857 1.0000 0.9857 0.9440 0.8784 0.7942 0.6977 0.8521 0.9139 0.9608 0.9900 1.0000 0.9900 0.9608 0.9139 0.8521 0.7788 0.9027 0.9440 0.9747 0.9936 1.0000 0.9936 0.9747 0.9440 0.9027 0.8521 0.9440 0.9681 0.9857 0.9964 1.0000 0.9964 0.9857 0.9681 0.9440 0.9139 0.9747 0.9857 0.9936 0.9984 1.0000 0.9984 0.9936 0.9857 0.9747 0.9608 0.9936 0.9964 0.9984 0.9996 1.0000 0.9996 0.9984 0.9964 0.9936 0.9900 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
zvol = trapz(x,trapz(y,z))
zvol = 158.0451
figure
surf(x, y, z)
grid on .
Star Strider on 17 Sep 2021
My pleasure!
.

R2020a

### Community Treasure Hunt

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

Start Hunting!