Hi, I'm a grad student with minimal matlab experience trying to complete this curve fit. My data has a logarithmic shape and is (hopefully) described by one ODE out of a system of 11 ODEs with 15 parameters. The only info I know is initial conditions of ODEs and some of the ratios of the parameters (so individual parameter values can vary greatly).
I have gotten my output to look logarithmic by manual manipulation of parameters (fig 1; data = blue, model = green circles), but when I try to get it to curve fit the output is always linear, usually intersecting in 2 places but sometimes not at all (fig 2: data = blue, model = green). (dont even know how its getting 10^22 with the bounds I specified)
I have heard of using global search as a possible solution, but I have the curve fitting toolbox and it doesnt like my system of ODE (probably because I dont know what im doing), so if someone can tell me that the global search toolbox will definitely work with a system of ODE then i'll give it a shot (because its going to take me forever lol).
curve fit code:
y = xlsread('dataforfitting.xlsx','B2:B1201');t = xlsread('dataforfitting.xlsx','A2:A1201');%init values for params
c0=[7000000000;.0000001;50000000;.000001;30000;.001;260000;.0001;.5;.05;.0000001;2;.1;450000000000000000000;.5];%bounds for params
lb = [6000000000;.0000001;40000000;.000001;20000;.0001;200000;.00001;.4;.01;.00000001;1;.01;300000000000000000000;.1];ub = [8000000000;.000001;500000000;.00001;300000;.01;300000;.001;.6;.1;.000001;5;1;550000000000000000000;1];%curve fit
options = optimoptions(@lsqcurvefit,'ScaleProblem','Jacobian','MaxIter',20000,'MaxFunEvals',20000);cfit = lsqcurvefit(@fitodes,c0,t,y,lb,ub,options);% See results
plot(t,y,'o',t,fitodes(cfit,t))
ode code:
function y = fitodes(c,x)% Define ODE system with parameter c
f = @(t,y,c) [c(1).*x(4)-c(2).*x(1).*x(3)+c(3).*x(6)-c(4).*x(1).*x(5);c(5).*x(5)-c(6).*x(2).*x(3)+c(7).*x(6)-c(8).*x(4).*x(2);c(9).*c(10).*x(10).^c(12).*x(10).^c(12)-c(9).*c(11).*x(11)+c(5).*x(5)-c(6).*x(2).*x(3)+c(1).*x(4)-c(2).*x(1).*x(3);-c(1).*x(4)+c(2).*x(1).*x(3)+c(7).*x(6)-c(8).*x(4);c(6).*x(2).*x(3)-c(5).*x(5)+c(3).*x(6)-c(4).*x(1).*x(5);-c(7).*x(6)+c(8).*x(4)-c(3).*x(6)+c(4).*x(5).*x(1)-c(13).*x(6);c(14)*c(15).*x(6)-x(7);c(13).*x(6)*c(15);c(13).*x(6)*(1-c(15));-c(10).*x(10).^c(12).*x(10).^c(12)+c(11).*x(11);c(10).*x(10).^c(12).*x(10).^c(12)-c(11).*x(11);];%error
options= odeset('RelTol',1e-6);%init conditions
init =[20000;75;0;0;0;0;0;0;0;.45;0;];%solve
[~,z] = ode45(@(t,y) f(t,y,c),x,init,options);% Extract desired solution component
y = z(:,7);
Best Answer