function vdpol2 t1=input('Solution starts at t=0: enter end time '); tspan=[0 t1]; counter=linspace(1,3,1); yo1=input('Enter initial value of x '); yo2=input('Enter initial value of xdot '); yo=[yo1; yo2]; global MUTEMP MUTEMP=input('Enter value of parameter mu '); function [value,isterminal,direction]=vdpolevents(t,y) value(1)=y(1); isterminal(1)=0; direction(1)=1; end options=odeset('Events',@vdpolevents); [t,y,te,ye] =ode45(@vdpol,tspan,yo,options); subplot(1,2,1) plot(t,y(:,1),te,ye(:,1),'o') title('van der Pol solution') subplot(1,2,2) plot(y(:,1),y(:,2)) [te] end