Borrar filtros
Borrar filtros

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

44 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 12 de Nov. de 2020
This is what fmincon does. Have you tried using that?
  5 comentarios
Cris LaPierre
Cris LaPierre el 12 de Nov. de 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.
Amara Kouyate
Amara Kouyate el 12 de Nov. de 2020
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Fit Postprocessing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by