Create a matrix with random integers between 1 and 9
古いコメントを表示
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!
採用された回答
その他の回答 (1 件)
Andrei Bobrov
2019 年 5 月 14 日
編集済み: Andrei Bobrov
2019 年 5 月 14 日
0 投票
[~,ii] = sort(rand(9,1));
out = reshape(ii,3,3);
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!