필터 지우기
필터 지우기

Custom curve fitting with constraint on parameters based on a value of estimated dependent variable (y)

조회 수: 44 (최근 30일)
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

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 11월 12일
This is what fmincon does. Have you tried using that?
  댓글 수: 5
Cris LaPierre
Cris LaPierre 2020년 11월 12일
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.
Amara Kouyate
Amara Kouyate 2020년 11월 12일
I think you bring up a good point that i did not think about before, i will see if i can obtaini a new set of data different from what i have now. because you said forcing the model is not a good option... maybe my data is not correct as you said. i will focus on trying to obtain a new set of data. Thank you again for your input.
Best,
Amara

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by