Uncommented MATLAB Code; fixed sample number jump bug