フィルターのクリア

How can i use this vector in my ODE function?

1 回表示 (過去 30 日間)
Jarl Bredal
Jarl Bredal 2023 年 12 月 6 日
回答済み: Torsten 2023 年 12 月 6 日
I have a vector of infusion rate values that i want to use in a differential equation. The infusion rates are given by this:
tspan = [0,60];
time_vals = 0:1:tspan(end);
SNP_infratevals = zeros(size(tspan));
for i = 1:length(time_vals)
if time_vals(i) > 0 && time_vals(i) <= 10
SNP_infratevals(i) = 30;
elseif time_vals(i) > 10 && time_vals(i) <= 20
SNP_infratevals(i) = 20;
elseif time_vals(i) > 20 && time_vals(i) <= 25
SNP_infratevals(i) = 6*(time_vals(i)-20)+20; % function
elseif time_vals(i) > 25 && time_vals(i) <= 35
SNP_infratevals(i) = 50;
elseif time_vals(i) > 35 && time_vals(i) <= 45
SNP_infratevals(i) = -4*(time_vals(i)-35)+50; % function
elseif time_vals(i) > 45 && time_vals(i) <= 50
SNP_infratevals(i) = 10;
elseif time_vals(i) > 50 && time_vals(i) <= tspan(end)
SNP_infratevals(i) = 25;
end
end
and i want to use it in my function : CVODE(t, y, SNP_infusion) as "u" in the line: dx2dt = 1/tau2 * (u-x2-(alpha*x3));
Do I need to interpolate maybe? If so how?

回答 (1 件)

Torsten
Torsten 2023 年 12 月 6 日
Integrate from t=0 to t=10 and use u = 30.
Restart the ode solver with the solution at t = 10 and integrate from t=10 to t = 20 with u = 20.
Restart the ode solver with the solution at t = 20 and integrate from t=20 to t = 25 with u = 6*(t-20)+20.
...

カテゴリ

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