Create a matrix with random integers between 1 and 9
Ältere Kommentare anzeigen
Hello.
I need help creating a 3x3 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!
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 14 Mai 2019
Bearbeitet: Andrei Bobrov
am 14 Mai 2019
0 Stimmen
[~,ii] = sort(rand(9,1));
out = reshape(ii,3,3);
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!