I'd start by returning the second, optional gof (goodness of fit) output variable that contains
Field Value
sse Sum of squares due to error
rsquare R-squared (coefficient of determination)
dfe Degrees of freedom in the error
adjrsquare Degree-of-freedom adjusted coefficient of determination
rmse Root mean squared error (standard error)
See the doc for fit for details...of course, I'd also want to plot the data and fitted results to ensure they make sense, not just rely on one or two statistics.
myfit1 = fittype('-2^(a.*x+b)+c','coefficients',{'a','b','c'});
[fit1,gof1] = fit(scantimes,data,myfit1,'StartPoint',[0.005,-2,0.4]);
myfit2 = fittype('exp(-d.*x+f)+g','coefficients',{'d','f','g'});
[fit2,gof2] = fit(scantimes,data,myfit2,'StartPoint',[0.04,1,0]);
Also, as a general coding paradigm I'd strongly recommend to consider recasting the variable naming scheme to use cell arrays or similar rather than using similar names with hardcoded numeric suffixes. Much simpler to generalize the code that way.
Best Answer