function [value,isterminal,direction] = exer6e(t,y,Z,state)
% The suitcase is vertical if y(1) = 0. It has fallen over
% if abs(y(1)) = pi/2.
value = [y(1); y(1)-pi/2; y(1)+pi/2];
% If vertical, terminate to reset y(2) and if fallen over,
% terminate to end the problem.
isterminal = ones(3,1);
% All events are to be reported.
direction = zeros(3,1);