MATLAB code to format the data collected