Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
Avishka Karunaratne
Avishka Karunaratne am 14 Feb. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (1)

Star Strider
Star Strider am 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]

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by