Home > lattice > insertelem0.m

insertelem0

PURPOSE ^

INSERTELEM0 - quick and dirty:

SYNOPSIS ^

function NEWLATTICE = insertelem0(LATTICE, DRIFTPOS, SPLITLENGTH, ELEMDATA)

DESCRIPTION ^

INSERTELEM0 - quick and dirty:
  inserts element(s) of zero length into a drift space

 NEWLATTICE = INSERTELEM0(LATTICE, DRIFTINDEX, SPLITLENGTH, ELEMDATA)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function NEWLATTICE = insertelem0(LATTICE, DRIFTPOS, SPLITLENGTH, ELEMDATA) 
0002 %INSERTELEM0 - quick and dirty:
0003 %  inserts element(s) of zero length into a drift space
0004 %
0005 % NEWLATTICE = INSERTELEM0(LATTICE, DRIFTINDEX, SPLITLENGTH, ELEMDATA)
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

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005