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!