MATLAB: Create a matrix with random integers between 1 and 9

homeworkMATLABmatrixrandom

Hello.
I need help creating a 3×3 matrix.
I need to create a matrix of integers between 1 and 9 allocated randomly each time and without repeating the same number.
Here's an example:
matrix =
9 7 3
5 1 8
4 2 6
Thanks!

Best Answer

>> reshape(randperm(9),3,3)
ans =
6 8 2
3 5 4
7 1 9