Fitting with coupled differential equations

16 ビュー (過去 30 日間)
Silke
Silke 2017 年 12 月 20 日
コメント済み: Silke 2017 年 12 月 21 日
Hi there,
I am trying to fit experimental data with a set of coupled differential equations (CDE). At the moment, using these CDEs does not give an error message, but also does not fit my data.
function dCC = DiffEq(t, x);
xdot(1,:) = phi_n - k_1n * x(1) - k_2 * x(1) * x(2);
xdot(2,:) = phi_n - k_1p * x(2) - k_2 * x(2) * x(1);
dCC = xdot;
end
[T,CCx] = ode45(@DiffEq, [t(1): dx : t(end)], [0 0]);
[xfit,resnorm, Jacob, CovB, MSE] = nlinfit( handles.timecorr,handles.datacorr',@DiffEqSolver, handles.x0 );
The problem I am having now, is that in principle the first term of both CDEs should be only non-zero in a certain time window, which is defined by pulses. If I just multiply phi_n with pulses in the first term of the differential equation, I end up with a matrix, which is not allowed in ode45. Is there any way to overcome this issue?
Thank you!
  2 件のコメント
Torsten
Torsten 2017 年 12 月 20 日
Could you include a graphic of "pulses" over time ?
Best wishes
Torsten.
Silke
Silke 2017 年 12 月 20 日
Yes, sure. I have included a figure showing the full pulse and a zoom-in the interesting region.

サインインしてコメントする。

採用された回答

Torsten
Torsten 2017 年 12 月 20 日
So I suspect that "pulses" is an (nx2) array with the first column being "time" and the second column being values between 0 and 1 ?
If this is the case, take a look at the example
"ODE with time-dependent terms"
under
https://de.mathworks.com/help/matlab/ref/ode45.html
It can directly be applied to your ODE-system.
Best wishes
Torsten.
  10 件のコメント
Torsten
Torsten 2017 年 12 月 21 日
編集済み: Torsten 2017 年 12 月 21 日
"ic" must be a vector with two components since you solve two differential equations. Thus "ic=0" must be replaced by something like ic=[0;0].
Best wishes
Torsten.
Silke
Silke 2017 年 12 月 21 日
Yes, indeed, this did the job. Thanks a lot for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by