0001 function NEWLATTICE = insertelem0(LATTICE, DRIFTPOS, SPLITLENGTH, ELEMDATA)
0002
0003
0004
0005
0006
0007 DRIFT1 = LATTICE{SPLITPOS};
0008 DRIFT1.Length = LATTICE{SPLITPOS}.Length*SPLITLENGTH;
0009 DRIFT2 = LATTICE{SPLITPOS};
0010 DRIFT2.Length = LATTICE{SPLITPOS}.Length*(1-SPLITLENGTH);
0011
0012 if DRIFTPOS==1
0013 NEWLATTICE = [{DRIFT1,ELEMDATA,DRIFT2},LATTICE(2:end)];
0014 elseif DRIFTPOS == length(LATTICE);
0015 NEWLATTICE = [LATTICE(1:end-1),{DRIFT1, ELEMDATA,DRIFT2 }];
0016 else
0017 NEWLATTICE = [LATTICE(1:DRIFTPOS-1), {DRIFT1,ELEMDATA,DRIFT2},LATTICE(DRIFTPOS+1)];
0018 end