I was not able to get this file to work unless I changed lines 970-971 from M[i, y_coor] = B[a, z] M[y_coor, i] = B[a, z] to M[i, y_coor-1] = B[a, z] M[y_coor-1, i] = B[a, z]