I realize my description wasn't very good. Here's some example code for matlab. I wasn't able to check it because I don't have MATLAB at home. I believe nlinfit requires the statistics and machine learning toolbox. It's very useful though!
[CODE lang="matlab" title="GaussianFitting"]% Make some data
x = 0:0.1:5;
y = 5*exp(-((x-3)/0.71).^2) + 1.7;
yerr = 0.1 + 0.2*rand(size(y));
% Plot the data
figure(1); clf;
errorbar(x,y,yerr,'ks')
% define a gaussian function to fit to
fitfun = @(b,x) b(1)*exp(-((x-b(2))/b(3)).^2)+b(4);
% b(1) is the amplitude of the gaussian line
% b(2) is the center value
% b(3) is the linewidth
% b(4) is the background
% define a vector of inverse-variance weights
w = yerr.^(-2);
% define a guess for the parameters of the gaussian
b0 = [1,0,1,0];
% use nlinfit to fit the data to a gaussian
[b,~,~,covB] = nlinfit(x,y,fitfun,b0,'weights',w);
% plot the result
hold on
plot(x,fitfun(b,x),'k--')
hold off
% print the uncertainty on the linewidth to the command window
display(['The linewidth uncertainty is: ',num2str(sqrt(covB(3,3)))])[/CODE]