function [A] = myMix(A); for i = 1 : 100 [x y] = find(A==0); direction = ceil(4*rand); if (direction==1 && x~=1) %hole up A(x,y)=A(x-1,y); A(x-1,y)=0; endif if (direction==2 && x~=3) %hole down A(x,y)=A(x+1,y); A(x+1,y)=0; endif if (direction==3 && y~=1) %hole left A(x,y)=A(x,y-1); A(x,y-1)=0; endif if (direction==4 && y~=3) %hole right A(x,y)=A(x,y+1); A(x,y+1)=0; endif ## A % if we remove the comment each step of mixing ## pause(0.1) % will be shown with 0.1s pause between each state endfor %B = A; endfunction