Home > pubtools > LatticeTuningFunctions > errors > setFieldIntegralError.m

setFieldIntegralError

PURPOSE ^

function rerr=setFieldIntegralError(r0,rerr,indx,order,Nsigma,sigmaperc)

SYNOPSIS ^

function rerr=setFieldIntegralError(r0,rerr,indx,order,Nsigma,sigmaperc)

DESCRIPTION ^

function rerr=setFieldIntegralError(r0,rerr,indx,order,Nsigma,sigmaperc)


see also: ApplyErrorRand

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function rerr=setFieldIntegralError(r0,rerr,indx,order,Nsigma,sigmaperc)
0002 %function rerr=setFieldIntegralError(r0,rerr,indx,order,Nsigma,sigmaperc)
0003 %
0004 %
0005 %see also: ApplyErrorRand
0006 rerr=PadPolynomAB(rerr);
0007 r0=PadPolynomAB(r0);
0008 
0009 % original value
0010 try
0011     kl=atgetfieldvalues(rerr,indx,'PolynomB',{1,order});
0012     kl(isnan(kl))=0;
0013 catch exc
0014     kl=zeros(size(dipindx));
0015 end
0016 
0017 % design value
0018 if order==1
0019     kl_0=atgetfieldvalues(r0,indx,'BendingAngle',{1,1});%bending angle
0020 else
0021     kl_0=atgetfieldvalues(r0,indx,'PolynomB',{1,order});%original model set of polynomB
0022 end
0023 
0024 % errors set
0025 kl_err=TruncatedGaussian(sigmaperc,Nsigma*sigmaperc,length(indx))'.*kl_0(:);% compute error starting from model values
0026 
0027 % previous set
0028 try
0029     kle=atgetfieldvalues(rerr,indx,'PolynomBErr',{1,order});
0030     kle(isnan(kle))=0;
0031 catch exc
0032     kle=zeros(size(indx));
0033 end
0034 
0035 newkl=kl(:)-kle(:)+kl_err(:);
0036 
0037 % new set
0038 rerr=atsetfieldvalues(rerr,indx,'PolynomB',{1,order},newkl);
0039 rerr=atsetfieldvalues(rerr,indx,'PolynomBErr',{1,order},kl_err);
0040 rerr=atsetfieldvalues(rerr,indx,'PolynomB0',{1,order},kl);
0041 
0042 return

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