Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Avoid combination between elements from the same category

2 visualizaciones (últimos 30 días)
Rachel Sabioni
Rachel Sabioni el 19 de Mzo. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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,

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de Mzo. de 2019
[P,Q] = ndgrid({'A', 'B', 'C'}, {'D', 'E'});
[P(:), Q(:)]
  1 comentario
Rachel Sabioni
Rachel Sabioni el 20 de Mzo. de 2019
Dear Mr. Walter,
It worked very well. Thank you so much for your help !
Rachel

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by