MATLAB code for project