Function File: ellipse = cov2ellipse (K)
Function File: [ra rb theta] = cov2ellipse (K)
Function File: … = cov2ellipse (…, ‘tol’,tol)

Calculates ellipse parameters from covariance matrix.

K must be symmetric positive (semi)definite. The optional argument ‘tol’ sets the tolerance for the verification of the positive-(semi)definiteness of the matrix K (see isdefinite).

If only one output argument is supplied a vector defining a ellipse is returned as defined in ellipses2d. Otherwise the angle theta is given in radians.

Run demo cov2ellipse to see an example.

See also: ellipses2d, cov2ellipse, drawEllipse.

Demonstration 1

The following code

 K = [2 1; 1 2];
 L = chol(K,'lower');
 u = randn(1e3,2)*L';

 elli = cov2ellipse (K)

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

Produces the following output

elli =

     0.00000     0.00000     1.73205     1.00000  -135.00000

and the following figure

Figure 1

Package: geometry