% Starting diary file diary-24-Nov-2010.txt % We're going to do problem 7.17 (paratrooper) from the text. edit ptf.m initialy = [600 ; 0] timespan = [0 100] ode23(@ptf,timespan,initialy); legend('height','speed') timespan = [0 20] ode23(@ptf,timespan,initialy); help odeset doc odeset edit eventfunction.m % "eventfunction" has the event y(1), i.e. hitting the ground. options = odeset('Events',@eventfunction) help ode23 ode23(@ptf,timespan,initialy,options); [T,Y] = ode23(@ptf,timespan,initialy,options); T Y help ode23 [T,Y,TE,YE,IE] = ode23(@ptf,timespan,initialy,options); T TE YE format long YE format short % Now I edited "eventfunction" to have the event t-5, i.e. chute opens at 5 sec timespan [T,Y,TE,YE,IE] = ode23(@ptf,timespan,initialy,options); T Y TE YE % Now I fiddled around some trying to specify more than one event ... % What finally turned out to work (after applying RTFM) was to have one % event function that returns a vector of two outputs for the two events. edit event1.m options = odeset('Events',@event1) [T,Y,TE,YE,IE] = ode23(@ptf,timespan,initialy,options); T TE YE diary off