MATLAB to match Andersons theory