You could certainly write your own function by using the gof output of the "fit" function. Here is an example that shows you how to use the "fit" to see the Goodness of Fit of different methods. You could store the "gof" values in an array and find the max GoF. function bestFitName = Gof_Finder( x, y )
Fits = {'poly1', 'poly2', 'poly3', 'exp1'};
for i=1:numel(Fits)
[~,GoFs(i)] = fit( x, y, Fits{i} );
end
[~, minIdx] = min([GoFs.sse]);
bestFitName = Fits{minIdx};
end
The above function will return the name of the best fit of the data x and y.
Best Answer