cleaned up and commented HRM matlab script and functions