MATLAB: Generate a rondom sequence

random number generator

Greetings,
Please can any one help me about:
How to Generate Generate a random sequence Z ={(i, j)},
where i, j Belongs to {1, 2, 3, 4}, i not equal to j
i and j are selected randomly.
Best Regards

Best Answer

or you can try :
a=1:4;
v=perms(a); % ALL possible combinations
Z=[v(:,1:2);v(:,3:4)];% Z is 2 columns