1. A method for analyzing movements of a handheld electronic device, comprising: calculating a matching score for a rotational string representation of rotational movement data for the device to a gesture string representing a gesture related to a command for the device by recursively traversing a matrix containing the rotational string representation, the gesture string representation and earlier movement data of the device using a distance edit algorithm to generate matching scores for values of the rotational string representation against the gesture string; and if a threshold for the matching score is met, executing a command associated with the gesture on the device.