필터 지우기
필터 지우기

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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by