Create a matrix with random integers between 1 and 9
11 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(1 个)
Andrei Bobrov
2019-5-14
编辑:Andrei Bobrov
2019-5-14
[~,ii] = sort(rand(9,1));
out = reshape(ii,3,3);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!