try this is code:
a=[11 11 22 22 33 33; 22 22 33 33 44 44; 44 44 11 11 22 22];
k = randi(size(a,2),size(a,1)-1,1);
b = a;
for j1 = 1:size(a,1)-1
b([j1,j1+1],k(j1)) = b([j1+1,j1],k(j1));
end
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!