Time dependent parameters in ode

Let’s say an non-linear first order ode...> dy_dt= c1-c2*e^y+1
  • define t_span as t= 1:10 and initial value is 0.1
  • c1=[1 1 2 2 3 4 4 3 1 0] and c2=[1 1 2 2 3 4 4 3 1 1]
  • c1 & c2 is also vector of 1*10
  • For every change in value of t from t_i-1 to t_i, c1 and c2 values should be updated in ode and final value of iteration t_i-1 should be initial value to t_i .Please suggest me how to proceed

댓글 수: 3

John D'Errico
John D'Errico 2016년 10월 30일
So are you telling us that c1 and c2 are actually functions of t? You will need to interpolate them, since the solver will usually need intermediate (non-integer) values of t.
PUJARI MURAGA
PUJARI MURAGA 2016년 10월 30일
Yes.exactly, at time t1, c1(1) and c2(1) should be updated with ic y0 and at time t2, c1(2) c2(2) should be updated with ic as y1......and so on
So use a spline. WTP? Or use interp1.
In your objective function, you know the value of t.
c1spl = spline(1:100,c1);
Pass it in and use it.

댓글을 달려면 로그인하십시오.

답변 (1개)

winkmal
winkmal 2019년 11월 13일

0 개 추천

Here is MathWorks official answer, and the corresponding paragraph from ode45 documentation.
Note that interp1 does linear interpolation by default, so you might need to change that.

카테고리

질문:

2016년 10월 30일

답변:

2019년 11월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by