MATLAB: Generate a random matrix without repeating any value in row and column.

MATLABnon repeating matrixrow repeationunique

How can I generate a random matrix without repeating any value in row and column. form "randi" function.
If we generate a matrix.
then the answer may be like this
randi(4,4)
ans =
4 2 3 1
3 4 1 2
1 3 2 4
2 1 4 3
this is just for example not generated matrix.
I have used the "unique" function. by this i can control the repeatition in row only.

Best Answer

A=mod((0:3)+(0:3)',4)+1;
R=A(randperm(end),randperm(end))