MATLAB: How to calculate the area from those charts

areachart;

I'm new here, so my question isn't very well structured. Sorry for that.
Is there any way to calculate the blue area from the 2d chart and the grey area (triangle/pyramid) from the 3d chart? It doesn't have to be 100% accurate. Thank you.

Best Answer

Regarding 2D area, you can use trapz or integral function.
As for the 3D volume of pyramid, you can simply utilize known formula: "volume = base area x height / 3". The following is an example.
% Given 4 points
pointA = [0.25 0.75 0];
pointB = [0.65 0.25 0.41];
pointC = [0.45 0.25 0];
pointD = [0.35 0.25 0];
% Calculate area of the base triangle ACD
x = [pointA(1) pointC(1) pointD(1) pointA(1)];
y = [pointA(2) pointC(2) pointD(2) pointA(2)];
triACD = polyarea(x,y);
% Calculate volume using the formula (volume = base area x height / 3)
volume = triACD * pointB(3) * (1/3);