ushuffle the matrix elements

1 回表示 (過去 30 日間)
Offroad Jeep
Offroad Jeep 2022 年 10 月 22 日
回答済み: John D'Errico 2022 年 10 月 22 日
let a be any mXm matrix
e.g.
a = magic(3)
8 1 6
3 5 7
4 9 2
i want to shuffle the elements of the matrix so that they go to different positions
please guide.... Regards....

採用された回答

John D'Errico
John D'Errico 2022 年 10 月 22 日
a = magic(3)
a = 3×3
8 1 6 3 5 7 4 9 2
reshape(a(randperm(numel(a))),size(a))
ans = 3×3
7 6 1 8 2 5 9 3 4

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by