Re: Discrete Event handling in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg68034] Re: Discrete Event handling in Mathematica
- From: "ben" <benjamin.friedrich at gmail.com>
- Date: Fri, 21 Jul 2006 05:37:21 -0400 (EDT)
- References: <e9nl3f$a0k$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Raj,
Does this do the job?
NDSolve[{\[Theta]'[t] == Sin[\[Theta][t]], \[Theta][0] == 0.5},
\[Theta], {t,
0, 100}, Method -> {EventLocator, "Event" -> \[Theta]l (t - tl) -
0.01,
"EventAction" :> Print["tl=", tl, ", \[Theta]=", \[Theta][t]]}]
Bye
Ben
Raj schrieb:
> Hi!
>
> Could somebody tell me if Mathematica can handle discrete events in
> Ordinary Differential Equations.
>
> For example in the following code
>
> Clear[\[Theta], \[Theta]l, tl]
> \[Theta]l = Sin[0.5]
> tl = 0;
> Reap[NDSolve[{\[Theta]'[t] == Sin[\[Theta][t]], \[Theta][0] ==
> 0.5}, \[Theta], {t, 0, 100},
> Method -> {EventLocator, "Event" -> \[Theta]l (t - tl) - 0.01,
> "EventAction" :> Sow[{tl = t, \[Theta]l = Sin[\[Theta][t]]}]}]]
>
> I want Mathematica to print out tl and \[Theta]l everytime the "Event"
> condition is met.
>
> Thanks,
>
> Raj