Home > lattice > ataddmpolecomppoly.m

ataddmpolecomppoly

PURPOSE ^

ataddmpolecomppoly adds a multipole component to an existing polynomial,

SYNOPSIS ^

function [PolynomOut] = ataddmpolecomppoly(Polynom,refindex,newindex,strength,radius,varargin)

DESCRIPTION ^

ataddmpolecomppoly adds a multipole component to an existing polynomial,
scaling it by the reference multipole value and a radius to set the length
scale
[PolynomOut] = ATADDMPOLECOMPPOLY(Polynom,index,strength,radius)

Polynom = given field polynomial that we want to add a component to
refindex = index of magnet: 1 for dipole, 2 for quadrupole
newindex: index of Multipole to add
strength: strength of the multipole component at the given radius
radius: reference radius for defining the absolute strength
 B^(N)_(n) = radius^(n-N)*b_n/b_N

See also: attiltelem, atshiftelem, atmodelem

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [PolynomOut] = ataddmpolecomppoly(Polynom,refindex,newindex,strength,radius,varargin)
0002 %ataddmpolecomppoly adds a multipole component to an existing polynomial,
0003 %scaling it by the reference multipole value and a radius to set the length
0004 %scale
0005 %[PolynomOut] = ATADDMPOLECOMPPOLY(Polynom,index,strength,radius)
0006 %
0007 %Polynom = given field polynomial that we want to add a component to
0008 %refindex = index of magnet: 1 for dipole, 2 for quadrupole
0009 %newindex: index of Multipole to add
0010 %strength: strength of the multipole component at the given radius
0011 %radius: reference radius for defining the absolute strength
0012 % B^(N)_(n) = radius^(n-N)*b_n/b_N
0013 %
0014 %See also: attiltelem, atshiftelem, atmodelem
0015 if (Polynom(refindex)==0)
0016     if nargin==5
0017         error('reference polynomial value is 0');
0018     else
0019        refvalue=varargin{1};
0020     end 
0021   
0022 else
0023     
0024    refvalue = Polynom(refindex);
0025 end
0026     
0027     
0028     if(newindex > length(Polynom))
0029         PolynomOut=[Polynom zeros(1,newindex-length(Polynom))];
0030     else
0031         PolynomOut=Polynom;
0032     end
0033     
0034     
0035     val=power(radius,newindex-refindex)*strength/refvalue;
0036     PolynomOut(newindex)=PolynomOut(newindex)+val;
0037 end

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