0001 function [NEWLATTICE, SHIFTEDINDEX] = rmelem0(LATTICE,ELEMINDEX)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 OLDN = length(LATTICE);
0016 NEWN = OLDN-length(ELEMINDEX);
0017
0018 THERING = cell(1,NEWN);
0019 NEWINDEX = zeros(size(ELEMINDEX));
0020
0021 ALLELEMS = 1:length(LATTICE);
0022 ALLELEMS(ELEMINDEX)=0;
0023 NZ = find(ALLELEMS);
0024
0025 for i = 1:length(NZ)
0026 NEWLATTICE{i}=LATTICE{NZ(i)};
0027 end
0028
0029
0030
0031 originalwarnstate = warning;
0032 warning off backtrace
0033
0034 newlength=findspos(NEWLATTICE,NEWN+1);
0035 oldlength=findspos(LATTICE,OLDN+1);
0036 if newlength~=oldlength
0037 error('Elements to be removed must have 0 physical length');
0038 end
0039
0040 SHIFTEDINDEX = 1+(ELEMINDEX(:)-(1:length(ELEMINDEX))');
0041 if size(SHIFTEDINDEX)~=size(ELEMINDEX)
0042 SHIFTEDINDEX=SHIFTEDINDEX';
0043 end
0044 if ELEMINDEX(end)==OLDN
0045 warning('Last element in the original LATTICE was removed');
0046 end
0047
0048 i = 1;
0049 while i<=length(ELEMINDEX)
0050 if ~strcmp(LATTICE{ELEMINDEX(i)}.PassMethod,'IdentityPass')
0051 warning('One or more removed elements used PassMethod other than ''IdentityPass''!');
0052 i = length(ELEMINDEX)+1;
0053 else
0054 i=i+1;
0055 end
0056 end
0057 warning(originalwarnstate);