Home > pubtools > LatticeTuningFunctions > errors > errorsmanipulation > getMagGroupsFromMagNum.m

getMagGroupsFromMagNum

PURPOSE ^

SYNOPSIS ^

function maggroups=getMagGroupsFromMagNum(r)

DESCRIPTION ^

 output maggroups in r given that the varaible MagNum is available in the
 lattice.
 maggroups is a cell array of magnet indexes describing a single magnet in
 reality, but sliced in the lattice
 a single magnet has the same MagNum value.
 
see also: SectorDipoleWithParallelFaces

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function maggroups=getMagGroupsFromMagNum(r)
0002 %
0003 % output maggroups in r given that the varaible MagNum is available in the
0004 % lattice.
0005 % maggroups is a cell array of magnet indexes describing a single magnet in
0006 % reality, but sliced in the lattice
0007 % a single magnet has the same MagNum value.
0008 %
0009 %see also: SectorDipoleWithParallelFaces
0010 
0011 maggroups={};
0012 
0013 magnumind=findcells(r,'MagNum');
0014 magnumval=getcellstruct(r,'MagNum',magnumind,1,1);
0015 
0016 imn=1;
0017 maggroupind=1;
0018 
0019 while imn<length(magnumval)
0020     
0021     eqcount=1;
0022     exitwhile=0;
0023     
0024     while magnumval(imn)==magnumval(imn+eqcount) && ~exitwhile
0025         if imn+eqcount<length(magnumval)
0026             eqcount=eqcount+1;
0027         else
0028             exitwhile=1;
0029         end
0030     end
0031     
0032     if exitwhile
0033         eqcount=eqcount+1;
0034     end
0035     
0036     maggroups{maggroupind}=magnumind(imn:imn+eqcount-1); %#ok<*AGROW>
0037     imn=imn+eqcount;
0038     maggroupind=maggroupind+1;
0039     
0040 end
0041 
0042 return

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