Matlab code for processing data