Matlab code for data analysis