Fitting Coupled ODE's to Multiple Sets of Experimental Data

4 次查看(过去 30 天)
I am currently trying to fit a set of coupled kinetic differential equations to to experimentally-obtained data such that:
Where I aim to find values for , , , , and ; I already have obtained values for α, β, , and . In my MATLAB function, I have defined yy which is an n by 3 matrix containing all three sets of X vs. t, S vs. t, and P vs. t data into my function against the ODE45-determined solution. The returned solution should provide the modelled transient behavior for X, S, and P vs. t in the same order as the equations provided above.
B0 = rand(5,1)*100;
[B, Rsdnrm, Rsd, Exflg, OptmInfo, Lmda, Jmat] = lsqcurvefit(@BFERMENT,B0,tt,yy);
function Y = BFERMENT(B,t,~)
%y(1) = X, y(2) = S_lac, y(3) = P_act
%B(1) = mu_max, B(2) = K_s, B(3) = K_i, B(4) = P_m, B(5) = k_d
S0 = 41.8;
X_0 = 0.01;
X0 = [X_0, S0, 0];
tspan = [0 53];
[T,SX] = ode45(@BFERMENTFIT,tspan,X0);
function dydt = BFERMENTFIT(t,y)
%P production model
alpha = 7.1328;
beta = 0.0825;
%S consumption model
Yps = 0.986;
Yxs = 0.093;
dydt = zeros(3,1);
dydt(1) = ((B(1).*y(2))./((1+B(2)./y(2)).*(1+y(2)./B(3)).*(1+(y(3)./B(4)).^4))-B(5)).*y(1);
dydt(3) = alpha.*dydt(1)+beta.*y(1);
dydt(2) = (-1/Yps).*dydt(3)-(B(1)./Yxs).*y(1);
end
if nargin == 2
Y = SX(:,1);
elseif nargin == 3
Y = SX;
end
end
However, whenever I try to run this script with my experimentally-obtained data, it returns an error message saying:
Error using lsqcurvefit. Function value and YDATA sizes are not equal.
Error in Data_Analysis. [B, Rsdnrm, Rsd, Exflg, OptmInfo, Lmda, Jmat] = lsqcurvefit(@BFERMENT,B0,tt,yy);
Would someone be able to help me pinpoint the issue with this? I've been racking my brain for hours trying to figure this out. It would be much appreciated.
  7 个评论
Nikhil Chellam
Nikhil Chellam 2020-4-5
编辑:Nikhil Chellam 2020-4-5
After fiddling around with the code some more, it appears that the lsqcurvefit terminates when the length of the Y-output matrix does not match the size of the y-data input. As ode45 is an adaptive runge-kutta method, it looks like the number of fitted data points per iterations changes. When the length of the matrix changes, then it terminates and returns the error message, as it does not match the size of the initial matrix passed to the function. For instance, I made the function output the size of the Y-output matrix each time lsqcurvefit called BFERMENT, such that
function Y = BFERMENT(B,t)
... %everything in the previously mentioned script stays the same
Y = SX;
disp(size(Y))
end
And after seeing the size of the Y-matrix the first time it ran, I made that the size of my test random data yy matrix to see what would happen as the script continued. The output is attached. It appears that the size of the output matrix changed, though I'm not sure how to control that. Do you have any suggestions?
Star Strider
Star Strider 2020-4-5
That can occur if ode45 encounters a singularity and then stops its integration, so the output is not the same size as the data (dictated by the size of the ‘tspan’ vector). I have no idea what else could be causing that problem.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by