How to create combinations of rows in an array?
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
Here is my problem:
I have an array:
data=[15 6;85 54;90 4;56 87;37 15;24 65]
% my input
I want to obtain the result that show combinations of rows for the above array, which would be:
15 6 15 6 15 6
85 54 85 54 85 54
90 4 90 4 90 4
56 87 56 87 24 65
37 15 24 65 56 87
24 65 37 15 37 15
And goes on until every row is in all available positions.
I am looking forward to your helps. Thanks a lot!
1 个评论
Rik
2020-12-9
Comment posted as flag by Anh Nguyen:
I have found another answer that gives a more clear output and suits my needs.
采纳的回答
Walter Roberson
2020-12-4
result = permute(reshape( data(perms(1:size(data,1)).',:).', size(data,2), size(data,1), []), [2 1 3]);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!