필터 지우기
필터 지우기

How to solve a system of differential equations that has a term expressed with interp1 function?

조회 수: 2 (최근 30일)
Hello,
I have a system of differential equations in which the derivatives are performed with respect to time. In some equations I have a term (not unknown) that depends on time because it is, at the specified time, the interpolation of a given curve (set of points), that is a curve that varies with time. I tried to solve with ode113 writing the interp1 function in the system inside the function that ode113 needs to work, but it seems that Matlab can't perform this task because if I change the values of the curve at some interpolation points, the result doesn't change. Instead if I change the initial conditions, the result changes (I think it is because Matlab solves the system with constant values assigned to the function interp1 that it pickes from the initial conditions, but I need it to solve for the whole curve not only for the initial conditions). Is there a way to solve my system?

채택된 답변

Walter Roberson
Walter Roberson 2018년 9월 2일
편집: Walter Roberson 2018년 9월 2일
Any time you have a system like that, you have discontinuities in the derivative of the function, and that makes it unsuitable for the ode*() routines, as the ode*() routines require continuity of the first two derivatives of the function being calculated. (In some cases, the delay differential routines are suitable.)
To get around this, you need to stop the integration at each of the breakpoints in the interpolation, and then resume again where you left off with the new value of the term. You would do this by looping, along the lines of
y0 = initial conditions
break_times = [.... list of times]
for K = 1 : length(break_times)-1
tspan = [break_times(K), mean(break_times(K:K+1)), break_times(K+1)];
[tK, yK] = ode113(@yourfunction, tspan, y0);
if K > 1; tK = tK(2:end); yK = yK(2:end,:); end
t{K} = tK: y{K} = yK;
y0 = YK(end,:);
end
t = vertcat(t{:});
Y = vertcat(y{:});

추가 답변 (0개)

카테고리

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