Matlab code for simulating snake movement