MERGEDRIFT removes a lattice element and merges the two adjacent drift spaces MERGEDRIFT (SPLITPOS) removes an element located at SPLITPOS from the global lattice THERING surrounded by two DRIFT spaces. The resulting drift has Length L0 = L1 + LSPLIT + L2; Number of elements in THERING is thus reduced by 2 See also: SPLITDRIFT
0001 function mergedrift(SPLITPOS) 0002 %MERGEDRIFT removes a lattice element and merges the two adjacent drift spaces 0003 % 0004 % MERGEDRIFT (SPLITPOS) removes an element located at SPLITPOS from the global lattice THERING 0005 % surrounded by two DRIFT spaces. The resulting drift has Length L0 = L1 + LSPLIT + L2; 0006 % Number of elements in THERING is thus reduced by 2 0007 % 0008 % See also: SPLITDRIFT 0009 0010 global THERING 0011 L0 = THERING{SPLITPOS-1}.Length + THERING{SPLITPOS+1}.Length + THERING{SPLITPOS}.Length; 0012 0013 0014 % make new (empty) THERING 0015 NEWN = length(THERING)-2; 0016 R = cell(1,NEWN); 0017 0018 N0 = length(THERING); % number of elements in THERING before split 0019 0020 for i = 1:(SPLITPOS-1) 0021 R{i} = THERING{i}; 0022 end 0023 0024 R{SPLITPOS-1}.Length = L0; 0025 0026 for i = SPLITPOS:NEWN 0027 R{i} = THERING{i+2}; 0028 end 0029 0030 THERING = R;