Code for MATLAB