Volume of Ellipsoid – MATLAB

Posted by Jeff Schuler on Aug 31, 2009 in Uncategorized |

This is how you calculate the volume of an ellipsoid with the following equation.

$x^{2}+ \frac{1}{4} y^{2} + \frac{1}{9} z^{2} \le 25$

rmax = 1;
V = 0;
step = 0.02;
A = 5;

B = 10;
C = 15;
for x= -5 : step : 5
for y = -10 : step : 10
for z = -15 : step : 15
if((x/A).^2 + (y/B).^2 + (z/C).^2) < rmax
V = V + step.^3;
end
end
end
end
disp(V)

it should spit out $1000 \pi$, approximately