function ellipsePDF(xo,yo,P,color)
%
% ELLIPSEPDF(X0,Y0,P,COLOR)
%  This function plots a set of ellipses defined by the covariance
%  matrix P centered at [xo,yo] in the current figure.  Three ellipses
%  are produced: one at 0.5std, one at 1std, and one at 2std.  The
%  ellipses are plotted in the color listed in the string COLOR.
%

hold on
t = [-pi:pi/50:pi];
[F,D] = eig(P);
sD1=sqrt(D(1,1));sD2=sqrt(D(2,2));
rx1=0.5*sD1;ry1=0.5*sD2;
rx2=1*sD1;ry2=1*sD2;
rx3=2*sD1;ry3=2*sD2;
x1(1,:)=rx1*cos(t);x1(2,:)=ry1*sin(t);xp1=F*x1;
x2(1,:)=rx2*cos(t);x2(2,:)=ry2*sin(t);xp2=F*x2;
x3(1,:)=rx3*cos(t);x3(2,:)=ry3*sin(t);xp3=F*x3;
plot(xp1(1,:)+xo,xp1(2,:)+yo,color)
plot(xp2(1,:)+xo,xp2(2,:)+yo,color)
plot(xp3(1,:)+xo,xp3(2,:)+yo,color)

