Function File: K = ellipse2cov (elli)
Function File: K = ellipse2cov (ra, rb)
Function File: K = ellipse2cov (…, theta)

Calculates covariance matrix from ellipse.

If only one input is given, elli must define an ellipse as described in ellipses2d. If two inputs are given, ra and rb define the half-lenght of the axes. If a third input is given, theta must be the angle of rotation of the ellipse in radians, and in counter-clockwise direction.

The output K contains the covariance matrix define by the ellipse.

Run demo ellipse2cov to see an example.

See also: ellipses2d, cov2ellipse, drawEllipse.

Demonstration 1

The following code

 elli = [0 0 1 3 -45];

 # Create 2D normal random variables with covarinace defined by elli.
 K = ellipse2cov (elli)
 L = chol(K,'lower');
 u = randn(1e3,2)*L';

 Kn = cov (u)

 figure(1)
 plot(u(:,1),u(:,2),'.r');
 hold on;
 drawEllipse(elli,'linewidth',2);
 hold off
 axis tight

Produces the following output

K =

   2   1
   1   2

Kn =

   2.1457   1.0276
   1.0276   1.9255

and the following figure

Figure 1

Package: geometry