Metlab code for processing data