Matlab data reading and preprocessing