Fitting experimental data to an ODE model, and performing optimization (Kinetic modeling)
9 次查看(过去 30 天)
显示 更早的评论
Dear,
I have experimental data (concentration vs. time), and I have an ODEs as a model to fit them to give the unknown parameters (k).
I have followed this answer: https://www.mathworks.com/matlabcentral/answers/77395-matlab-code-for-system-of-differential-equations-chemical-kinetics-fitting-to-data
However, I have this error message: "Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-9.", I checked and it belonged to opt function.
Also, I do not have a solution for my ODEs?
Best regards,
global td cd ci ki
T = readtable('experimental_data.xlsx','Sheet',2);
T1= T.Variables;
td= T1(:,1); %experimet time
cd= [T1(:,4), T1(:,3),zeros(9,1),T1(:,2),T1(:,5),zeros(9,1),T1(:,6),T1(:,7),T1(:,8)]; %species concentration
ci= [0.136 0.193 0 0.271 0 0 0 0 0]'; %initial concentration
ki= [1 1 1 1 1 1 1 1 1 1]'; %initial k guess
opt = fminsearch(@(k) optim(td,cd,k,ci), ki); %optimization function (ERROR)
function dc = diff(k,t,C)
r1= (-k(1)* C(1))/(1+ k(10) * C(5));
r2= (k(1) * C(1) - k(2) * C(2))/(1+ k(10) * C(5));
r3= (k(2) * C(2) - k(3) * C(3))/(1+ k(10) * C(5));
r4= (k(3) * C(3) - k(3) * C(3))/(1+ k(10) * C(5));
r5= (k(4) * C(4) - k(5) * C(5) -k(6)*C(5))/(1+ k(10) * C(5));
r6= (k(6) * C(5) - k(7) * C(6) -k(8)*C(6))/(1+ k(10) * C(5));
r7= (k(8) * C(6) - k(9) * C(7))/(1+ k(10) * C(5));
r8= (k(5) * C(5) + k(7) * C(6))/(1+ k(10) * C(5));
r9= (k(9) * C(7))/(1+ k(10) * C(5));
dc = [r1;r2;r3;r4;r5;r6;r7;r8;r9];
end
function SSE = optim(td,cd,k,ci)
global td cd ci
f = @(t,C) diff(k,t,C);
[tm, cm] = ode45(f, td, ci); %cm is the concentration predicted by the model
err = cd - cm;
SSE = sum(err.^2); %sum squared-error.
end
1 个评论
Star Strider
2020-3-2
One you may want to review is: Parameter Estimation for a System of Differential Equations and of course: Monod kinetics and curve fitting .
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!