Create a matrix with random integers between 1 and 9
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Enric Gironès
il 14 Mag 2019
Modificato: Andrei Bobrov
il 14 Mag 2019
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!
0 Commenti
Risposta accettata
Più risposte (1)
Andrei Bobrov
il 14 Mag 2019
Modificato: Andrei Bobrov
il 14 Mag 2019
[~,ii] = sort(rand(9,1));
out = reshape(ii,3,3);
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!