ATSETSHIFT sets the misalignment vectors RING=ATSETSHIFT(RING, ELEMINDEX, DX, DY) sets the entrance and exit misalignment vectors of one element or a group of elements in the globally defined lattice THERING. ELEMINDEX contains indexes of elements to be misaligned DX, DY are displacements of the ELEMENT so the coordinate transformation on the particle at entrance is X -> X-DX Y -> Y-DY ATSETSHIFT(ELEMINDEX, DX, DY) Uses the global variable THERING See also: ATSETTILT
0001 function ring=atsetshift(varargin) 0002 %ATSETSHIFT sets the misalignment vectors 0003 % 0004 % RING=ATSETSHIFT(RING, ELEMINDEX, DX, DY) sets the entrance and exit misalignment vectors 0005 % of one element or a group of elements in the globally defined lattice THERING. 0006 % 0007 % ELEMINDEX contains indexes of elements to be misaligned 0008 % DX, DY are displacements of the ELEMENT 0009 % so the coordinate transformation on the particle at entrance is 0010 % X -> X-DX 0011 % Y -> Y-DY 0012 % 0013 % ATSETSHIFT(ELEMINDEX, DX, DY) Uses the global variable THERING 0014 % 0015 % See also: ATSETTILT 0016 0017 global THERING 0018 if ~iscell(varargin{1}) 0019 THERING=atsetshift(THERING,varargin{:}); 0020 else 0021 [ring,idx,dx,dy]=deal(varargin{:}); 0022 0023 if length(dx) == 1 0024 dx=dx*ones(size(idx)); 0025 elseif length(dx) ~= length(idx) 0026 error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(dx)); 0027 end 0028 if length(dy) == 1 0029 dy=dy*ones(size(idx)); 0030 elseif length(dy) ~= length(idx) 0031 error('AT:length','Vector lengths are incompatible: %i/%i.',length(idx),length(dy)) 0032 end 0033 0034 for i = 1:length(idx) 0035 ring{idx(i)}=atshiftelem(ring{idx(i)},dx(i),dy(i)); 0036 end 0037 end