I want to solve an ode with a time dependent parameter.
cA should 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
cAit has not the correct values at the specified times. - if
tupis e.g. 20cBhas values, iftupis e.g. 100cBis zero.