MATLAB: How to create an m by n matrix with each row having the numbers 1 to n in a random order

how do i create an m by n matrix with each row having the numbers 1 to n in a random order?

How do I create an m by n matrix with each row having the numbers 1 to n in a random order?

Best Answer

[~,ii] = sort(rand(m,n),2)