generating sequence of given numbers

1 回表示 (過去 30 日間)
fyza affandi
fyza affandi 2019 年 2 月 24 日
コメント済み: fyza affandi 2019 年 2 月 24 日
Given an array A
A=[0 1 2]
How can I generate different sequence of number in that array like below;
A=[0 2 1]
A=[1 0 2]
A=[2 0 1]
A=[1 2 0]
A=[2 1 0]

採用された回答

Stephen23
Stephen23 2019 年 2 月 24 日
編集済み: Stephen23 2019 年 2 月 24 日
>> A = [0,1,2];
>> M = perms(A)
M =
2 1 0
2 0 1
1 2 0
1 0 2
0 1 2
0 2 1
And if you really want to remove that row from the output:
>> M = setdiff(perms(A),A,'rows')
M =
0 2 1
1 0 2
1 2 0
2 0 1
2 1 0
  1 件のコメント
fyza affandi
fyza affandi 2019 年 2 月 24 日
Thank you very much :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by