function D=beamdata(M,guess) %Imports array of beam characterization measurements. Structure of M is % [z, x, I, a] where z is the displacement of the beam blockage along % the optical axis, x is the coordinate of razor edge, I is the measured % output of the photodetector and a is the ambient light level %and guess is an estimate of the parameters [Amplitude x0 width] for the %first measurement %Output Structure [z A x0 w residual_2norm] thisfile=mfilename('fullpath'); thisdir=strrep(thisfile,mfilename(),''); zdat=M(:,1); xdat=M(:,2)-M(:,4); Idat=M(:,3); measnum=size(xdat); measnum=measnum(:,1); D=[]; n=1; N=[]; loopend=0; while (n<(measnum)*loopend==0)==1 i=1; if n+18