MATLAB: Least squares curve fit only uses the guess

gaussianlsqcurvefitMATLABtolfuntolx

I'm trying to fit a curve to 3 gaussian curves. I have decreased TolX and TolFun down to 2e-16 but it always uses my guess, even when I make them obviously incorrect. Too much lower on these parameters makes the code never terminate, and any termination always says the solution converged even though the plots are way different.
Here is a plot where the guess is pretty close, the red is the actual signal, the black lines are the individual gaussian curves, and the blue is the sum of them (the fit)
Here is one where I intentionally skewed the peak locations but the algorithm terminated even with the above tolerances.
Here is the code for the 3 gaussian functions:
guess=[6.8e-4; 24e-19; 1.48e9; 3.1e-4; 17e-18; 2.587e9; 1.47e-3; 3.1e-18; 3.693e9];%1.48e9 2.587e9 3.693e9
lb=[0;0;1e6; 0;0;1e9; 0;0;1e9];
ub=[20e-3; 1.5e-17; 3e9; 15e-3; 5e-17; 5e9; 50e-3; 2.3e-10; 4e9];
opts = optimset('MaxFunEvals',2000000,'MaxIter',200000,'TolFun',2e-16,'TolX',2e-16);
GaussFit1=@(Xo,freq)(Xo(1).*exp((-Xo(2).*(freq-Xo(3)).^2))+Xo(4).*exp((-Xo(5).*(freq-Xo(6)).^2))+Xo(7).*exp((-Xo(8).*(freq-Xo(9)).^2)));
[FitCoef,RESNORM,RESIDUAL] = lsqcurvefit(GaussFit1,guess,freq,F5(FreqMin:FreqLim),lb,ub,opts);
I can send the .m file if anyone wants it but the vector used for the actual data (in red in the plots) is about 2550 points so too long to post I think.
Thanks

Best Answer

The fit is highly ill-conditioned because of the very large difference in the orders of magnitude of your parameters. You should measure frequency in units 10^9 times larger and you should measure the signal amplitude in units 10^3 times smaller than the units you are using now.