I have been given an assignement for a graphics module, one part of which is to calculate the minimum bounding ellipse of a set of arbitrary shapes. The ellipse doesn't have to be axis aligned.
This is working in java (euch) using the AWT shapes, so I can use all the tools shape provides for checking containment/intersection of objects.
You're looking for the Minimum Volume Enclosing Ellipsoid, or in your 2D case, the minimum area. This optimization problem is convex and can be solved efficiently. Check out the MATLAB code in the link I've included - the implementation is trivial and doesn't require anything more complex than a matrix inversion.
Anyone interested in the math should read this document.
Also, plotting the ellipse is also simple - this can be found here, but you'll need a MATLAB-specific function to generate points on the ellipse.
But since the algorithm returns the equation of the ellipse in the matrix form,
matrix form http://mathurl.com/yz7flxe.png
you can use this code to see how you can convert the equation to the canonical form,
canonical http://mathurl.com/y86tlbw.png
using Singular Value Decomposition (SVD). And then it's quite easy to plot the ellipse using the canonical form.
Here's the result of the MATLAB code on a set of 10 random 2D points (blue).
Other methods like PCA does not guarantee that the ellipse obtained from the decomposition (eigen/singular value) will be minimum bounding ellipse since points outside the ellipse is an indication of the variance.
EDIT:
So if anyone read the document, there are two ways to go about this in 2D: here's the pseudocode of the optimal algorithm - the suboptimal algorithm is clearly explained in the document:
Optimal algorithm: