How can I create this matrix?

1 visualización (últimos 30 días)
Sourasis Chattopadhyay
Sourasis Chattopadhyay el 4 de Ag. de 2021
Comentada: Walter Roberson el 19 de Ag. de 2021
  1 comentario
KSSV
KSSV el 4 de Ag. de 2021
An example will hep us to help you.

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 4 de Ag. de 2021
n = 5;
r = 2:5;
F = @(k)any(permute(nchoosek(1:n,k),[3,1,2])==(1:n).',3);
M = cell2mat(arrayfun(F,r,'uni',0))
M = 5×26 logical array
1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 1 1 1 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 0 1 1 0 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 1 1 0 1 1 1 1 1
  4 comentarios
Sourasis Chattopadhyay
Sourasis Chattopadhyay el 19 de Ag. de 2021
Thank you for you answer .
Walter Roberson
Walter Roberson el 19 de Ag. de 2021
You might be able to fit the 50 case. Change to
F = @(k)any(permute(nchoosek(uint8(1:n),k),[3,1,2])==uint8(1:n).',3);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by