notes and corrected matlab code