function [value,isterminal,direction] = events(t,x) % Locate the time when displacement passes through zero in a % decreasing direction and stop integration. value = x(1); isterminal = 1; direction = -1;