I am trying to use a different starting point for my custom equation in the MatLab curve fitting tool. I was able to define a fix starting point for my parameters a,b,c, and o. i.e. opts.StartPoint = [25.364 26.01 1.02 4.6] I want to do a for loop that can try 10 different starting points until reaching the original starting point [25.364 26.01 1.02 4.6]. This is what I did so far, and my data is just a table with x and y. x = age of pavement that goes from 1 to 20 and y = pavement roughness data that goes from 2.4 to 4.6
thank you for your help, this is my code below:
function [fitresult, gof] = FitTestPSI(x, y)
S = uiimport('-file');
x = S.data(:,1);
y = S.data(:,2);
[xData, yData] = prepareCurveData( x, y );
ft = fittype( 'o-exp(a-b*c^log(1/x))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Algorithm = 'Levenberg-Marquardt';
opts.Display = 'Off';
opts.StartPoint = [25.364 26.01 1.02 4.6];
[fitresult, gof] = fit( xData, yData, ft, opts );
disp(gof.sse);
disp(gof.rmse);
figure( 'Name', 'PSI' );
h = plot( fitresult, xData, yData );
legend( h, 'Measured', 'Estimated', 'Location', 'NorthEast');
text(15,3.2,sprintf('SSE = %g\nRMSE = %g',gof.sse,gof.rmse))
xlabel AGE(year)
ylabel PSI
title('Orig. BIT Constr.')
grid on
end