Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'probleme with eventLocator method' topicStudent Support Forum > General > "probleme with eventLocator method"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Michael
06/03/12 10:08pm

In Response To 'Re: Re: Re: probleme with eventLocator method'
---------
The semicolon after Reap means the result of Reap is discarded. Also your call to sol[..] does not match the definition in the notebook you attached. (It seems to match the one from my previous file, but that one may not be what you want.)

p = {1, 1.1};
While[p[[2]] < 1.2, z = zt[p[[2]], p[[1]], t0];
ss = Block[{tf = 0, xf = 0, yf = 0, dxf = 0},
Reap[While[tf < 10, Sow[sol[p, tf, xf, yf, dxf]]]][[2, 1]]; (*<-- *)
p = {p[[2]], p[[2]] + z};]]

Putting Reap outside Block will give a result, but maybe not what you want:
ss = Reap[
Block[{tf = 0, xf = 0, yf = 0, dxf = 0},
While[tf < 10, Sow[sol[p[[1]], tf]]]; (*<-- or p[[2]]? Or? *)
p = {p[[2]], p[[2]] + z};]][[2, 1]]

It save only the result of the last iteration of the While loop in the variable ss. The previous results are discarded.

Also keep in mind that While returns Null unless Return is used.

To remove the vertical lines in the plot, try
Plot[f, {t, 0, 10}, Exclusions -> (#[[1, 1, 2, 1, 1, 2]] & /@ ss)]
where ss is list of solutions as in your notebook.

URL: ,

Subject (listing for 'probleme with eventLocator method')
Author Date Posted
probleme with eventLocator method Lyna 05/21/12 04:48am
Re: probleme with eventLocator method Michael 05/25/12 3:30pm
Re: Re: probleme with eventLocator method Lyna 05/29/12 05:44am
Re: Re: Re: probleme with eventLocator method Michael 05/29/12 7:19pm
Re: probleme with eventLocator method Lyna 05/30/12 12:44pm
Re: Re: probleme with eventLocator method Michael 05/31/12 8:34pm
Re: Re: Re: probleme with eventLocator method Lyna 06/03/12 5:03pm
Re: Re: Re: Re: probleme with eventLocator method Michael 06/03/12 10:08pm
Re: Re: Re: Re: Re: probleme with eventLocator ... Lyna 06/07/12 09:08am
Re: Re: Re: Re: Re: Re: probleme with eventLoca... Michael 06/08/12 07:31am
Re: Re: Re: Re: Re: Re: Re: probleme with event... Lyna 06/10/12 06:26am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic