cleaned up matlab wrapper, now analogous to Python code