Compute permutations of vector and output as cell arrays

3 ビュー (過去 30 日間)
Scott
Scott 2014 年 10 月 28 日
回答済み: Sean de Wolski 2014 年 10 月 28 日
I'm trying to calculate all of the permutation of a given vector, and then output these values in it's own cell array
i.e. A = [1 2 3] output = 3 2 1 3 3 1 2 1 1 2
If i use perms(A), it gives me all of the permutations, except that it is in matrix form, i.e. [1 2 3;1 3 2;2 3 1;2 1 3;3 1 2;3 2 1]
Is there a way i can take this output, and output each row of the matrix as it's own cell array?

回答 (1 件)

Sean de Wolski
Sean de Wolski 2014 年 10 月 28 日
A = [1 2 3]
num2cell(perms(A),2)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by