SCAN decoder MATLAB Implementation