Main Question or Discussion Point

Hi guys,
I have a differential equation in NDSolve and for example lets say it is just one equation. Based on some time value, I would like to add another differential equation in the NDSolve function and then the system will solve two ODEs. For example,

y' = 2 with y[0] = 1

Let says I run the code from t = 0 until t = 100. I would like Mathematica to add another differential equation in the NDSolve function as soon as it reachs time, lets say, t = 50. So at t = 50 I would then have

x' = x - y with x[50] = 1

Is there a way to do this in Mathematica? Any help would be appreciated. I was able to setup x' as a piecewise function so that when t >= 50 I can turn on x' = x - y but then the initial conditions will be a problem cause I cant setup initial conditions as a piecewise function. Thanks for your help

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
The initial conditions apply to both equations, always. Its just a matter of when they're used. Try putting both conditions in, outside of the piece-wise function definition.

I tried this:

s = NDSolve[{m'[t] == If[t >= 50, 0.003, 0], n'[t] == 1, m[0] == 10, n[0] == 19000}, {n, m}, {t, 0, 100}]
Plot[Evaluate[m[t] /. s], {t, 0, 100}, PlotRange -> All]

Only problem is that m[0] should be 0 but m[50] = 100 and I am not sure how to put that in the code. Any suggestions? Thanks

Hi,

Would this work:

Code:
mysol = NDSolve[{y'[t] == 2, x'[t] == UnitStep[t - 50] (x[t] - y[t]),
y[0] == 1, x[0] == 1}, {y, x}, {t, 0, 100}]
not sure though.

Thanks for giving it a shot but still not luck. I want x[t] = 0 until t < 50 and then on t >=50, the x'[t] function should take over with the starting condition x[50] = 1. I think somehow the EventLocator for NDSolve can be used but i just don't know how. Any help would be appreciated.