Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Avoid combination between elements from the same category
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dears,
I would like to combine elements from a matrix. These elements are categorized and elements from the same category cannot be combined.
Modules = ({'M1'; 'M1'; 'M1'; 'M2'; 'M2'}) %Matrix with my categories
MI = ({'A'; 'B';'C';'D';'E'}) %Matrix with my elements
B = nchoosek(MI, 2)
T =
5×2 table
Modules MI
_______ ______________________
'M1' 'A'
'M1' 'B'
'M1' 'C'
'M2' 'D'
'M2' 'E'
Table T shows in which categoy of module each MI is comprised.
I want to create a matrix B in which I will combine 2 elements by row, excluding all combinations of elements from the same category of module.
Could you help me ?
Thanks in advance,
0 Kommentare
Antworten (1)
Walter Roberson
am 19 Mär. 2019
[P,Q] = ndgrid({'A', 'B', 'C'}, {'D', 'E'});
[P(:), Q(:)]
1 Kommentar
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!