Changing params and grid to be global

MATLAB passes to function by value and not by reference