% MatLab example to read image data, display, create a plot profile, and
% fit the plot profile to a Gaussian
I=imread('beam1.bmp');
I = I(:,:,1);  % all three RGB bytes are the same so only use the first one
imshow(I);
% this next function allows you to get a profile of the intensity along a
% path that you select.  Left click to start and right click to end
% x and y are the (x,y) positions along the path
[x,y,intensity] = improfile; 
% move the orgin to the start of the path
x=x-x(1);
y=y-y(1);
d = (x.^2+y.^2).^.5;  % calaculate the distance along the path in pixels
hold off;  % make a new figure
plot(d,intensity); % see what this looks like
% now fit the data; this next line will do the fit or you can use cftool if
% you prefer a GUI approach
pfit = fit(d,intensity,'gauss1');  % this will return the fit
hold on;  % overlay the fit with the data
plot(d,pfit(d),'r');  % plot fhe fit
pfit % and echo the fit parameters
