Having an problem with a Mathcad WHILE loop (using Mathcad 15). I'm reading data in from a file, the data is from an accelerometer. I want to set up an IF statement to set a variable to 1 when the rising edge of the signal is greater than 5 g's but I don't want to reset the variable back to 0 until the signal drops to below 2 g's. If I do just the IF statement it work fine but switches the variable to 1 on the rising edge of the pulse at 5 g's and sets it back to 0 on the falling edge at 5 g's. I want the variable to be reset back to 0 at 2 g's on the falling edge. Attached is my attempt of a WHILE loop inside a IF statement, I'm having issues trying to determine how to structure the WHILE loop. Any help with this would be appreciated. Attached is a PDF of the waveform and my attempt at the Mathcad programming.