Custom curve fitting with constraint on parameters based on a value of estimated dependent variable (y)
27 views (last 30 days)
Show older comments
Amara Kouyate
on 12 Nov 2020
Commented: Amara Kouyate
on 12 Nov 2020
Hello everyone,
I am working on developing deterioration model for road pavement condition data for my thesis. I have been using the Matlab curve fitting tool with a custom deterioration model. I have my x (age of pavement) and y (condition index) data. my model equation is y = o-exp(a-b*c^log(1/x)). I am estimating coefficient a, b, c and o based on some constraints. I was able to do all that but i am stuck with a constrain that I dont know how to formulate.
My current curve fitting code is giving parameters (a,b,c and o) that when i use them in the equation to estimate y, my y =2.7 is around x = 55. Since i have aready my x and y data, i am trying to develop a constraint that will force Matlab to estimate parameters a, b, c and o that will give a y value equal or around 30 at age x=2.7.
below is my code and attached the excel data. Thank you in advance and let me know if you have any question.
function [fitresult, gof] = bestCoefPDIcon(x, y)
S = uiimport('-file'); %this gives option to automatically select excel file
% It will show an error message but wait until a pop window show
x = S.data(:,1);
y = S.data(:,2);
[xData, yData] = prepareCurveData( x, y );
% Set up fittype and options.
ft = fittype( 'o-exp(a-b*c^log(1/x))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
%[3.611 5.638 1.27 5] are actual parameters for PDI CON activity 16 (OC-CON)
% PDI CON min coef value [1.715 2.361 1.02 4.8]
% PDI CON max coef value [43.733 44.779 2.631 5]
aMin = 1.715;
bMin = 2.361;
cMin = 1.02;
oMin = 4.8;
aMax = 43.733;
bMax = 44.779;
cMax = 2.631;
oMax = 5;
opts.Lower = [aMin 0 1 0]; % set lower bond coef A = lowest value of coef A for BIT pavement
% set lower bond coef B & O = 0, and coef C =1
opts.StartPoint = [0 0 0 0];
opts.Upper = [aMax bMax cMax oMax]; % set upper bond coef A = highest value of coef B for BIT pavement
% set upper bond coef B & C = infinity, and coef O = max value of coef O for BIT pavement
%[3.611 5.638 1.27 5] are actual parameters for PDI CON activity 16 (OC-CON)
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts )
% Plot fit with data.
figure( 'Name', 'PDI' );
h = plot( fitresult, xData, yData );
legend( h, 'Measured', 'Estimated', 'Location', 'NorthEast');
% Label axes
xlabel AGE(year)
ylabel PDI
grid on
0 Comments
Accepted Answer
Cris LaPierre
on 12 Nov 2020
5 Comments
Cris LaPierre
on 12 Nov 2020
Perhaps. I'd be concerned that you are no longer fitting a model to your data. There is a bigger issue you should explore about either how the data was collected, or the assumptions being made about what is "correct". Forcing an 'expected' fit is not a good solution.
More Answers (0)
See Also
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!