If I am understanding r correctly, you want to move the respective rows from their current positions to that position plus r(i). I recommend creating an indexing matrix for this, and then using sortrows to perform the reorientation.
I am also assuming that if a relative shift is greater than the number of rows you want to go 'around the horn' and start back up at the top. (i.e. the last row is position + 1, which would make it the first row.)
sr = [1:size(ww,1)];
sr = sr'+r';
sr(sr>size(sr,1)) = sr(sr>size(sr,1))-size(sr,1);
ww = [sr,ww];
ww = sortrows(ww);
ww = ww(:,2:end);