Home > pubtools > LatticeTuningFunctions > errors > wave > seterrorwave.m

seterrorwave

PURPOSE ^

SYNOPSIS ^

function rwave=seterrorwave(r,... % nominal lattice

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function rwave=seterrorwave(...
0002     r,...             % nominal lattice
0003     positions,...      % positions where to apply the error
0004     errorsetfunct,... % function handle to set the error
0005     wavelength,...    % wavelength [m]
0006     amplitude,...     % amplitude [m]
0007     existingerr)        
0008 %
0009 %  rwave=seterrorwave(...
0010 %     r,...             % nominal lattice
0011 %     position,...      % positions where to apply the error
0012 %     errorsetfunct,... % function handle to set the error
0013 %     wavelength,...    % array of wavelengths [m]
0014 %     amplitude)        % array of amplitudes [m]
0015 %
0016 % sets error waves. errors are defined and applid by the function
0017 % errorsetfunct with signature r=errorsetfunct(r,positions,erroval)
0018 %
0019 %see also: findspos
0020 if nargin<6
0021 existingerr=zeros(size(positions));
0022 end
0023 
0024 nw=length(amplitude);
0025 np=length(positions);
0026 
0027 spos=findspos(r,positions);
0028 
0029 %errorvalues=zeros(size(positions));
0030 
0031 sposdivwave = bsxfun(@rdivide, repmat(spos,nw,1), wavelength');
0032 sinsposdivwave=sin(2*pi*sposdivwave);
0033 
0034 sinusoidsmat=repmat(amplitude,np,1).*sinsposdivwave';
0035 errorvalues=sum(sinusoidsmat,2)';
0036 
0037 %plot(spos,errorvalues)
0038 %errorvalues=amplitude*sin(2*pi*spos/wavelength);
0039 
0040 rwave=errorsetfunct(r,positions,existingerr+errorvalues);
0041 
0042 return

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