applying fix from matlab to unity. Also making unity output points to .m file so matlab can be using exactly the same stuff (for debugging)