time dependent parameter in ode-function matlab

조회 수: 1 (최근 30일)
sejo
sejo 2014년 7월 23일
댓글: kiran gk 2016년 11월 20일
I want to solve an ode with a time dependent parameter. cA sould be 10000 if t is >=10 and <=11 else it should have the value of 0. cA is then used in an differential equation to calculate cB. See the code:
function dcB = myode(t,y)
cB=y(1,:);
if t>=10 && t<=11
cA=10000
else
cA=0
end
dcB=(cA-cB)*100/1750;
[t,y]=ode45(@myode,[tdown tup],0);
Fallowing problems show up:
  • if i print cA it has not the correct values at the specified times.
  • if tup is e.g. 20 cB has values, if tup is e.g. 100 cB is zero.

채택된 답변

Mischa Kim
Mischa Kim 2014년 7월 23일
Sejo, one fairly clean approach would be to split the integration interval: [tdown 10),[10 11],(11 tup] and call ode45 three times with two separate ODE functions. You'd just have to make sure that the final conditions of the respective previous integration are passed on as initial conditions to the next integration.
  댓글 수: 1
kiran gk
kiran gk 2016년 11월 20일
What if cA has multiple values with respect to t? In that case it will be difficult to create multiple ode function please suggest the possible answer

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

추가 답변 (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