필터 지우기
필터 지우기

Unable to perform curve fitting

조회 수: 2 (최근 30일)
Niya Bedzheva
Niya Bedzheva 2020년 9월 1일
댓글: Alex Sha 2020년 9월 2일
Hello everyone,
I have been struggling for a while doing a nonlinear regression to a simple set of data. I wanted to perform it with the curve fitting tooldbox, but somehow it can't fit the data to my model equasion.
I have my custom equasion of this type: (a*(0.03^2)+b*0.03+c)*(exp(-d*x)+f*exp(-g*x)) and as a result i get:
I have also tried with nlinfit and fitnlm functions but the results are super sensitive on the initial values for the parameters which leads to unacurate results for a,b,c,d,f and g.
The final idea is to use the calculated model parameters and then define new calues for my Deff (Coefficient of effective diffusion) with different values for ksi (hydromodule)
clc;
clear all;
ksi=0.03;
tao=[300 600 900 1200 1800 3600 5400 7200 27000];
DeRR=[3.90592997493998e-09 2.35848864487335e-09 1.84176664779469e-09 1.58252065132943e-09 1.32075697832129e-09 1.03628002341392e-09 8.81177774572414e-10 7.28508407391888e-10 2.00749829156030e-10];
beta0=[0 0 0 0 0 0];
stupid=@(a,tao)(a(1)*(ksi^2)+a(2)*ksi+a(3))*((exp(-a(4)*tao)+a(5)*exp(-a(6)*tao)));
beta = nlinfit(tao,DeRR,stupid,beta0);
a(1)=beta(1);
a(2)=beta(2);
a(3)=beta(3);
a(4)=beta(4);
a(5)=beta(5);
a(6)=beta(6);
ksin=[0.01];
Dcal=(a(1).*(ksin.^2)+(a(2).*ksin)+a(3)).*((exp(-a(4).*tao)+(a(5).*exp(-a(6).*tao))));
plot(tao,DeRR,'ko',tao,Dcal,'b-')
legend('Data','Deff 0.01','Deff 0.02')
title('Deff')
I would appreciate any suggestions regarding to the curve fitting toolbox (how to work with my model equasion) or the script, because i am writing a bachelor thesis.
Thank you very much in advance!
  댓글 수: 1
Alex Sha
Alex Sha 2020년 9월 2일
Hi, Niya, first of all, there is a problem with your fitting function, the part of "(a(1)*(ksi^2)+a(2)*ksi+a(3))" can be substitued by "a(1)*(ksi^2)", otherwise, parameters of a(1), a(2) and a(3) will not be stable, that is there will have infinite cobminations among them. So if fitting function become DeRR=a1*(ksi^2)*((exp(-a4*tao)+a5*exp(-a6*tao))), the unique result could be obtained as below:
Root of Mean Square Error (RMSE): 4.80014676010325E-11
Sum of Squared Residual: 2.07372680266768E-20
Correlation Coef. (R): 0.998998426725134
R-Square: 0.997997856599293
Adjusted R-Square: 0.997330475465725
Parameter Best Estimate
---------- -------------
a1 6.61536444129772E-6
a4 0.00304744048933963
a5 0.260714360113999
a6 0.000101021724906286

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by