0001 function line = atdivelem(elem,frac)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 line=atsetfieldvalues(repmat({elem},length(frac),1),'Length',elem.Length*frac(:));
0022 if isfield(elem,'T1')
0023 line(2:end)=cellfun(@(elem) rmfield(elem,'T1'),line(2:end),'UniformOutput',false);
0024 end
0025 if isfield(elem,'R1')
0026 line(2:end)=cellfun(@(elem) rmfield(elem,'R1'),line(2:end),'UniformOutput',false);
0027 end
0028 if isfield(elem,'T2')
0029 line(1:end-1)=cellfun(@(elem) rmfield(elem,'T2'),line(1:end-1),'UniformOutput',false);
0030 end
0031 if isfield(elem,'R2')
0032 line(1:end-1)=cellfun(@(elem) rmfield(elem,'R2'),line(1:end-1),'UniformOutput',false);
0033 end
0034 if isfield(elem,'BendingAngle')
0035 line=atsetfieldvalues(line,'BendingAngle',elem.BendingAngle*frac(:)/sum(frac));
0036 end
0037 if isfield(elem,'EntranceAngle')
0038 drentrangle=zeros(size(line));
0039 drentrangle(1)=elem.EntranceAngle;
0040 line=atsetfieldvalues(line,'EntranceAngle',drentrangle);
0041 end
0042 if isfield(elem,'ExitAngle')
0043 drexitangle=zeros(size(line));
0044 drexitangle(end)=elem.ExitAngle;
0045 line=atsetfieldvalues(line,'ExitAngle',drexitangle);
0046 end
0047 if isfield(elem,'FringeInt1')
0048 fringe1=zeros(size(line));
0049 fringe1(1)=elem.FringeInt1;
0050 line=atsetfieldvalues(line,'FringeInt1',fringe1);
0051 end
0052 if isfield(elem,'FringeInt2')
0053 fringe2=zeros(size(line));
0054 fringe2(end)=elem.FringeInt2;
0055 line=atsetfieldvalues(line,'FringeInt2',fringe2);
0056 end
0057 if isfield(elem,'FringeBendEntrance')
0058 fringe1=zeros(size(line));
0059 fringe1(1)=elem.FringeBendEntrance;
0060 line=atsetfieldvalues(line,'FringeBendEntrance',fringe1);
0061 end
0062 if isfield(elem,'FringeBendExit')
0063 fringe2=zeros(size(line));
0064 fringe2(end)=elem.FringeBendExit;
0065 line=atsetfieldvalues(line,'FringeBendExit',fringe2);
0066 end
0067 if isfield(elem,'FringeQuadEntrance')
0068 fringe1=zeros(size(line));
0069 fringe1(1)=elem.FringeQuadEntrance;
0070 line=atsetfieldvalues(line,'FringeQuadEntrance',fringe1);
0071 end
0072 if isfield(elem,'FringeQuadExit')
0073 fringe2=zeros(size(line));
0074 fringe2(end)=elem.FringeQuadExit;
0075 line=atsetfieldvalues(line,'FringeQuadExit',fringe2);
0076 end
0077
0078 if isfield(elem,'FullGap')
0079 fringe2=zeros(size(line));
0080 fringe2([1,end])=elem.FullGap;
0081 line=atsetfieldvalues(line,'FullGap',fringe2);
0082 end
0083 if isfield(elem,'EdgeEffect1')
0084 fringe2=zeros(size(line));
0085 fringe2(1)=elem.EdgeEffect1;
0086 line=atsetfieldvalues(line,'EdgeEffect1',fringe2);
0087 end
0088 if isfield(elem,'EdgeEffect2')
0089 fringe2=zeros(size(line));
0090 fringe2(end)=elem.EdgeEffect2;
0091 line=atsetfieldvalues(line,'EdgeEffect2',fringe2);
0092 end
0093
0094 end