function [value,isterminal,direction] = exam7e(t,y,Z,state) xb = -0.427; value = Z - xb; isterminal = 1; direction = 0;