semplotemit.m 499 Bytes
Newer Older
Simone Liuzzo's avatar
Simone Liuzzo committed
1 2 3
function semplotemit(sig)
%SEMPLOTEMIT Plot emittance ellipse
%   Detailed explanation goes here
4 5 6 7
if sig(2,2)<=1e-3
    sig(2,2) = 1e-3;
    warning('zero initial vertical emittance');
end
Simone Liuzzo's avatar
Simone Liuzzo committed
8 9 10 11 12 13 14 15 16 17
emittance2=sig(1,1)*sig(2,2)-sig(1,2)*sig(2,1);
xmax=2*sqrt(sig(1,1));
[xx,zz]=meshgrid(linspace(-xmax,xmax,80),linspace(-0.8*xmax,0.8*xmax,120));
dd=exp(-(sig(2,2)*xx.*xx-(sig(1,2)+sig(2,1))*xx.*zz+sig(1,1)*zz.*zz)/2/emittance2);
%surf(xx,zz,dd);
contourf(xx,zz,dd,'LineColor','none');
axis equal
grid on
end