Here is code that fits w and t1 as you requested. For a starting guess [w,t1]=[1,1], the console output and plot are below.
Best fit: SumSqError=0.377, w=3.791, t1=0.00000217
That does not look like a great fit, so I changed line 4 of SomnathMain2.m to a different initial guess:
The fit was a lot better from this initial guess - see output below, and note the reduction in SumSqError.
Best fit: SumSqError=0.020, w=1.036, t1=0.00000330
To find a better fit, I suggest A. try different starting points, to make sure you have not gotten stuck in a local minimu that is not a global minimum, or B. modify the code to fit "A" and/or "n" in addition to "w" and "t1".
Option B. should be pretty obvious, based on the code I have provided. You need to make the necessary adjustments in both SomnathsFunc2.m and SomnathMain2.m.
Option A. is a bit trickier, to do in a programmatic way, but worth doing. I do option A. whenever I fit parameters of a non-trivial model. The basic idea for option A is:
Define a generous physically reasonable range for each parameter (err on the side of too big a range). Then make an array of inital guesses (i.e. each row is a possible value to a0, the initial guess). The values might be chosen to be at 20% and 80% of the range, and you try all the combinations. So if you are fitting two parameters, and the reasonable ranges are a1=[-10,+10] and a2=[0, 1] respectively, then you'll have four starting points, which are
[-9, 0.1; +9, 0.1; -9, 0.9; +9, 0.9];
You do the fit four times. Save the residual error and fitted parameters from each initial guess. After doing the four fits, pick the parameters that gave the best fit. Sometimes I try 10%, 50%, and 90% of the range as my initial guesses. In that case, I have 3^N initial guesses to try, where N=number of fitted parameters.