pchip vector in ODE45 equation

2 ビュー (過去 30 日間)
Philip Berg
Philip Berg 2016 年 10 月 18 日
コメント済み: Philip Berg 2016 年 10 月 18 日
Hello, I'm currently trying to make a script that takes some variable x, with some parameters p, and a fitted curve z (fitted with
FLM_Beta12 = pchip(Data(:,1),x(:,5),tSpan)
). tSpan is the first time point in the data (=ts) to the last one (=te), and looks like ts:0.01:te, Data is a column of the actual time points of measurement, and x is the measurements.
The ODE function is as follows:
function dFTdt = Beta(t,x,p,z)
FT=x(1);
alpha = p(1);
beta = p(2);
ki=p(3);
FLM_Beta = z;
dFTdt = zeros(1,1);
dFTdt(1) = beta - FLM_Beta(t) * ki - FT * alpha;
end
For some reason when I debug the script t is always a 1x1 matrix (with the value 1). And this is how I call the ODE:
[~,yx] = ode45(@(t,x) Beta12(t,x,parameters,FLM_Beta),tSpan,FT12(1))
Where parameters is a row vector of 3 values. FT is a column vector with data. I have been trying a lot of different ways to call it, but I think the issue is with the fitted curve and that 'FLM_Beta(t)' isn't calling one value at the time. Any help, or a link in the right direction is very welcome. If I haven't provided enough details of the problem, please let me know!

採用された回答

Torsten
Torsten 2016 年 10 月 18 日
FLM_Beta12 = pchip(Data(:,1),x(:,5));
[~,yx] = ode45(@(t,x) Beta(t,x,parameters,FLM_Beta12),tSpan,FT12(1));
function dFTdt = Beta(t,x,p,z)
FT=x(1);
alpha = p(1);
beta = p(2);
ki = p(3);
FLM_Beta = z;
dFTdt = zeros(1,1);
dFTdt(1) = beta - ppval(FLM_Beta,t) * ki - FT * alpha;
end
Best wishes
Torsten.
  1 件のコメント
Philip Berg
Philip Berg 2016 年 10 月 18 日
Thank you!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by