function [xx yy] = rotate(x, y, th) % rotate the x and y vectors mat = [cos(th) -sin(th); sin(th) cos(th)]; for i = 1:length(x) xp(1) = x(i); xp(2) = y(i); xr = mat * xp'; xx(i) = xr(1); yy(i) = xr(2); end