data fitting starting from a coupled system of differential equations
古いコメントを表示
I have a coupled system of differential equations, which I defined in the following way:
dx= zeros(2,1);
dx(1)=K1*K2*x(1)*x(2)./(K3+x(2));
dx(2)= -K1*x(1)*x(2)./(K3+x(2));
I have some experimental data for x(1) at a given time grid. (I have about 30 values).
I would like to find the values of the parameters K1,K2,K3 such that the solution of the ODE fits these experimental data.
How can i program this in matlab?? I'd like to use a least square minimisation to get my parameters... how can I use the function ''lsqcurvefit'' in the optimisation toolbox starting from a coupled system of differential equations??
thank you very much in advance.
simona
採用された回答
その他の回答 (2 件)
owr
2012 年 4 月 4 日
0 投票
I would start by figuring out how to simulate the system for some fixed values of K1, K2, etc. and sample this numerical solution at exactly the points in time where you have your experimental data sampled. Check out ode45 or something similar.
Richard Brown
2012 年 4 月 15 日
Hi Simona. I'm adding this as a new answer so that I can use code markup. You need a function that takes in K1, K2, K3 as inputs, and returns all the deviations (if you're using lsqnonlin), or the sum of the squared deviations (if you're using something like fminsearch). It may also be useful to have a flag that you can set if you want graphical output.
You can do it fairly neatly using nested functions. I'll give you the overall structure, I'm sure you can fill in the details. T and X are your data values and times.
function r = foo(K1, K2, K3, T, X, is_plotting)
x0 = blah;
[~, Y] = ode45(@myode, T, x0)
if is_plotting
plot(T, Y, 'b', T, X, 'rx');
end
% The format of this line depends on what solver you use
r = sum(X - Y).^2;
function dx = myode(t, x)
% Because myode is nested, it can "see" K1, K2, and K3
dx = [K1*K2*x(1)*x(2)./(K3+x(2));
-K1*x(1)*x(2)./(K3+x(2))];
end
end
end
1 件のコメント
Arbol
2017 年 6 月 5 日
you can use lsqcurvefit for this to estimate the parameters correct?
カテゴリ
ヘルプ センター および File Exchange で Solver Outputs and Iterative Display についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!