All the posible combination of two matrices
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have two matrix
A=[1]
and
B=[2 3 4]
find the all possible combination of these tow matrices is
the output
C=[1 2; 1 3; 1 4; 1 2 3; 1 2 4; 1 3 4; 1 2 3 4]
how to find it
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 17 de Dic. de 2012
Editada: Andrei Bobrov
el 17 de Dic. de 2012
C = [];
for j1 = 1:numel(B)
a = nchoosek(B,j1);
C = [C;num2cell([repmat(A,size(a,1),1),a],2)];
end
3 comentarios
Más respuestas (1)
Walter Roberson
el 17 de Dic. de 2012
You cannot create a numeric matrix with a variable number of elements in each row.
4 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!