Updated matlab codes