ATSIGMA constructs a beam sigma matrix 2x2 4x4 or 6x6 SIGMA=ATSIGMA(BETA,ALPHA,EMIT) builds a 2x2 sigma matrix for a transverse plane SIGMA=ATSIGMA(ESPREAD,BLENGTH) builds a 2x2 sigma matrix for the longitudinal plane SIGMA=ATSIGMA(BETAX,ALPHAX,EMITX,BETAZ,ALPHAZ,EMITZ) builds a 4x4 sigma matrix SIGMA=ATSIGMA(BETAX,ALPHAX,EMITX,BETAZ,ALPHAZ,EMITZ,ESPREAD,BLENGTH) builds a 6x6 sigma matrix SIGMA=ATSIGMA(ATSTRUCT) builds a 6x6 sigma matrix See also atx
0001 function sigma = atsigma(varargin) 0002 %ATSIGMA constructs a beam sigma matrix 2x2 4x4 or 6x6 0003 % 0004 % SIGMA=ATSIGMA(BETA,ALPHA,EMIT) 0005 % builds a 2x2 sigma matrix for a transverse plane 0006 % 0007 % SIGMA=ATSIGMA(ESPREAD,BLENGTH) 0008 % builds a 2x2 sigma matrix for the longitudinal plane 0009 % 0010 % SIGMA=ATSIGMA(BETAX,ALPHAX,EMITX,BETAZ,ALPHAZ,EMITZ) 0011 % builds a 4x4 sigma matrix 0012 % 0013 % SIGMA=ATSIGMA(BETAX,ALPHAX,EMITX,BETAZ,ALPHAZ,EMITZ,ESPREAD,BLENGTH) 0014 % builds a 6x6 sigma matrix 0015 % 0016 % SIGMA=ATSIGMA(ATSTRUCT) 0017 % builds a 6x6 sigma matrix 0018 % 0019 % See also atx 0020 0021 if iscell(varargin{1}) 0022 beamdata=atx(varargin{1},0,1); 0023 sigma=beamdata(1).beam66; 0024 elseif nargin == 2 0025 [espread,blength]=deal(varargin{:}); 0026 sigma=[espread.*espread 0;0 blength.*blength]; 0027 elseif nargin == 3 0028 [bx,ax,epsx]=deal(varargin{:}); 0029 sigma=epsx*[bx -ax;-ax (1+ax*ax)/bx]; 0030 elseif nargin == 6 0031 [bx,ax,epsx,bz,az,epsz]=deal(varargin{:}); 0032 sigma=[atsigma(bx,ax,epsx) zeros(2,2);... 0033 zeros(2,2) atsigma(bz,az,epsz)]; 0034 else 0035 [bx,ax,epsx,bz,az,epsz,espread,blength]=deal(varargin{:}); 0036 sigma=[atsigma(bx,ax,epsx) zeros(2,4);... 0037 zeros(2,2) atsigma(bz,az,epsz) zeros(2,2);... 0038 zeros(2,4) atsigma(espread,blength)]; 0039 end 0040 0041 end