Home > atphysics > findspos.m

findspos

PURPOSE ^

FINDSPOS returns longitudinal positions of accelerator lattice elements.

SYNOPSIS ^

function spos = findspos(line,refpts)

DESCRIPTION ^

FINDSPOS returns longitudinal positions of accelerator lattice elements.
  Return value is a row vector of positions S at the entrance of each
  element specified REFPTS (index list or logical mask)

 Note: REFPTS is an array of increasing indexes that
   select elements from range 1 to length(LATTICE)+1.
   REFPTS is allowed to go 1 point beyond the
   number of elements. In this case the last point is
   the EXIT of the last element. If LATTICE is a RING
   it is also the entrance of the first element after 1 turn.

   Note:
   1. Use findspos(RING,1:length(RING)) for to find
      longitudinal position of all elements
   2. Use findspos(LINE,length(LINE)+1) to find the
      total physical length
   3. If line is a closed ring, exit of the last element
      is also the entrance to the first.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function spos = findspos(line,refpts)
0002 %FINDSPOS returns longitudinal positions of accelerator lattice elements.
0003 %  Return value is a row vector of positions S at the entrance of each
0004 %  element specified REFPTS (index list or logical mask)
0005 %
0006 % Note: REFPTS is an array of increasing indexes that
0007 %   select elements from range 1 to length(LATTICE)+1.
0008 %   REFPTS is allowed to go 1 point beyond the
0009 %   number of elements. In this case the last point is
0010 %   the EXIT of the last element. If LATTICE is a RING
0011 %   it is also the entrance of the first element after 1 turn.
0012 %
0013 %   Note:
0014 %   1. Use findspos(RING,1:length(RING)) for to find
0015 %      longitudinal position of all elements
0016 %   2. Use findspos(LINE,length(LINE)+1) to find the
0017 %      total physical length
0018 %   3. If line is a closed ring, exit of the last element
0019 %      is also the entrance to the first.
0020 
0021 if isvector(line)
0022     L=[0;cumsum(cellfun(@(el) el.Length,line(:),'ErrorHandler',@(w,el) 0))];
0023 else
0024     L=[0;cumsum(cellfun(@(el) el.Length,line(:,1),'ErrorHandler',@(w,el) 0))];
0025 end
0026 spos=L(refpts)';
0027 end

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