Info

This question is closed. Reopen it to edit or answer.

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

1 view (last 30 days)
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

Answers (1)

Star Strider
Star Strider on 14 Feb 2016
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]

This question is closed.

Community Treasure Hunt

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

Start Hunting!