MATLAB: To choose and shift an element randomly

MATLABmatrixmatrix manipulation

I have a matrix as below:
a=[11 11 22 22 33 33; 22 22 33 33 44 44; 44 44 11 11 22 22]
a=
11 11 22 22 33 33
22 22 33 33 44 44
44 44 11 11 22 22
Then, I need to do matrix operation as algorithm below:
1. In row 1, I need to choose an element randomly. 2. I need to shift the element with next row shift. For example, if 22 is chosen, it need to shift with 33. So, it will become like this:
b=
11 11 33 22 33 33
22 22 22 33 44 44
44 44 11 11 22 22
3. I will do this operation for next rows too.
Therefore, I need any help to code this problem.

Best Answer

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