MATLAB Code for my thesis