Copied over matlab stuff from myth machine