Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = 10;
- sol = NDSolve[{x'[t] == -10, x[0] == 10}, x, {t, 0, 10}];
- Plot[Evaluate[x[t] /. sol], {t, 0, 10}, PlotRange -> All]
- Clear[a];
- sol = NDSolve[{x'[t] == -a[t], x[0] == 10, a'[t] == 0, a[0] == 10,
- WhenEvent[x[t] == 0, a[t] -> 0]}, x, {t, 0, 10}];
- Plot[Evaluate[x[t] /. sol], {t, 0, 10}, PlotRange -> All]
- solval = Piecewise[{{#[t], #[[1, 1]] <= t <= #[[1, 2]] &@#["Domain"]}}] &@
- NDSolveValue[{x'[t] == -10, x[0] == 10,
- WhenEvent[x[t] < 0, "StopIntegration"]}, x, {t, 0, 10}];
- Plot[solval, {t, 0, 10}, PlotRange -> All]
- solval = NDSolveValue[{x'[t] == -10, x[0] == 10,
- WhenEvent[x[t] < 0, "StopIntegration"]}, x, {t, 0, 10},
- "ExtrapolationHandler" -> {0 &, "WarningMessage" -> False}]
- a = 10;
- sol = NDSolve[{x'[t] == If[x[t] >= 0, -10, 0], x[0] == 10}, x, {t, 0, 10}];
- Plot[Evaluate[x[t] /. sol], {t, 0, 10}, PlotRange -> All]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement