% Fits beamwidth versus position data to a Gaussian beam profile function f=fitgaussianbeamrad(z,w,lambda,varargin) if nargin>3, startparams=varargin{1}; else w0=1e-3; z0=0; startparams=[w0,z0]; end if nargin>4, displayoptions=varargin{2}; else displayoptions=[1 0 0]; end f=genfit(z,w,startparams,@beamrad,'nonlin',displayoptions); function w=beamrad(params,z) w=beamradius([params,lambda],z); % Want 1/e^2 Power radius end end