Matlab version of GPMSA