Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to find all combinations of 3 of matrices but get the results named

1 次查看(过去 30 天)
I have 1X1 matrices A = 2, B= 4 , C5 =10 , D=2 etc , basically 40 of such matrices, (I dont mind combining them into one matrix) I want every possible combination of 3 but a way to know which matrices made up each matrix.
for e.g if i get the combination 2 4 10 , I want to know that it came from D, B and C

回答(1 个)

Star Strider
Star Strider 2016-2-14
One possibility:
VblNames = {'A' 'B' 'C5' 'D'};
VblVals = {2, 4, 10, 2};
idx = nchoosek(1:size(VblNames,2), 3);
Out = {VblNames(idx); VblVals(idx)};
Out{:}
ans =
'A' 'B' 'C5'
'A' 'B' 'D'
'A' 'C5' 'D'
'B' 'C5' 'D'
ans =
[2] [ 4] [10]
[2] [ 4] [ 2]
[2] [10] [ 2]
[4] [10] [ 2]

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by