Fitting experimental data to an ODE model, and performing optimization (Kinetic modeling)
조회 수: 8 (최근 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!