Matlab Code for Thesis