Accelerating the pace of engineering and science

# ellipsoid

Generate ellipsoid

## Syntax

[x,y,z] = ellipsoid(xc,yc,zc,xr,yr,zr,n)
[x,y,z] = ellipsoid(xc,yc,zc,xr,yr,zr)
ellipsoid(axes_handle,...)
ellipsoid(...)

## Description

[x,y,z] = ellipsoid(xc,yc,zc,xr,yr,zr,n) generates a surface mesh described by three n+1-by-n+1 matrices, enabling surf(x,y,z) to plot an ellipsoid with center (xc,yc,zc) and semi-axis lengths (xr,yr,zr).

[x,y,z] = ellipsoid(xc,yc,zc,xr,yr,zr) uses n = 20.

ellipsoid(axes_handle,...) plots into the axes with handle axes_handle instead of the current axes (gca).

ellipsoid(...) with no output arguments plots the ellipsoid as a surface.

## Examples

expand all

### Surface Plot of Ellipsoid

Generate data for an ellipsoid with a center at (0,0,0) and semi-axis lengths (5.9,3.25,3.25). Use surf to plot the ellipsoid.

```[x, y, z] = ellipsoid(0,0,0,5.9,3.25,3.25,30);
figure
surf(x, y, z)
axis equal
```

expand all

### Algorithms

ellipsoid generates the data using the following equation:

$\frac{{\left(x-xc\right)}^{2}}{x{r}^{2}}+\frac{{\left(y-yc\right)}^{2}}{y{r}^{2}}+\frac{{\left(z-zc\right)}^{2}}{z{r}^{2}}=1$

Note that ellipsoid(0,0,0,.5,.5,.5) is equivalent to a unit sphere.