Parameter estimation for a system of differential equations with multiple time spans

8 次查看(过去 30 天)
Hello,
I've got four sets of experimental data with variables c1(t1), c2(t2), c3(t3) and c4(t4), each with their own time scale that is not common for all.
I'm interested in estimating two parameters, x1 and x2, of a model so that the parameters are the best fit for the four data sets, i.e. I want to fit one x1 and one x2 for all data-sets together, not one set of x per data set.
I've successfully managed to apply this to all four data sets (i.e. 4 ODEs) that are called in lsqcurvefit.
However, I can only manage to do this with one time vector with length equal to the longest C-vector.
This is not what I want, since the experimental data is dependent on four different time scales, the lsqcurvefit will fit one of the data sets good, while the remaining thee become erroneous.
So, is it possible to solve for and fit based on each time series?
% What I've got currently:
c = [c1, c2, c3, c4]
t = t1
% but I want:
c = [c1,c2,c3,c4]
t = [t1 t2 t3 t4]
% which is then called in:
x = lsqcurvefit(@one_ODE,x0,t,c)
% where ODE is a call to a function that solves one ODE per concentration
% (4 in total), that has another function nested in it, e.g.:
function C = one_ODE(x,t)
c0 = [54 0 27 0];
[T,Cv] = ode45(@DifEq, t, c0);
function dC = DifEq(t,c)
dcdt = zeros(4,1);
dcdt(1) = - ((x(1).*c(1)) + (x(2).*c(1).*c(2)));
dcdt(2) = ((x(1).*c(1)) + (x(2).*c(1).*c(2)));
dcdt(3) = - ((x(1).*c(3)) + (x(2).*c(3).*c(4)));
dcdt(4) = ((x(1).*c(3)) + (x(2).*c(3).*c(4)));
dC = dcdt;
end
C = Cv; %
end
Thanks in advance.
Kind regards,
Jakob

采纳的回答

Star Strider
Star Strider 2021-3-19
This is definitely a new problem!
The usual way of dealing with it would be to vertically concatenate the time vectors and objective function matrices, and present all of them to lsqcurvefit at once, since lsqcurvefit ‘doesn’t care’ about the order of its inputs so long as they match.
I would be tempted to try something like this:
data{1} = readmatrix('File1.ext');
% . . .
data{4} = readmatrix('File4.ext');
function Cmat = cat_ODE(data)
for k = 1:4
t = data{k}(:,1);
Ccat{k,:} = oneODE(x,t);
end
Cmat = cell2mat(Ccat);
end
for k = 1:4
tcat = data{k}(:,1);
ycat{k,:} = data{k}(:,2:5);
end
tv = cell2mat(tcat);
ydata = cell2mat(ycat);
lsqcurvefit(@cat_DDE, x0, tv, ydata)
This assumes the the time vector is in the first column of the data sets, and that the other information are in the last four columns.
That is the only approach I can see to this problem. It would obviously be necessary to experiment with it.
  84 个评论
Star Strider
Star Strider 2021-4-18
As always, my pleasure!
I will experiment with fitnlm to see if I can get the variables presented to it to work. I do not understand the difference between it and lsqcurvefit such that it fails with fitnlm and works with lsqcurvefit.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by