Generating combination of matrix with 3 elements

1 visualización (últimos 30 días)
Shourya
Shourya el 16 de Feb. de 2022
Comentada: Shourya el 15 de Mzo. de 2022
I want to optimally generate a 100 matrix, of size MxN using the combination of 3 elements (0,1,2) and save them into seperate mat files. Can someone please help. I dont want to generate the matrix randomly.
  3 comentarios
Shourya
Shourya el 16 de Feb. de 2022
@David Hill @Jan I am sorry about that. I want to generate 100 mat files in more optimal way when it comes to the series of 3 elements in a row. I dont want to repeat the rows in a matrix. My matrix size is 64x12. Is there a way I can do it?

Iniciar sesión para comentar.

Respuesta aceptada

David Hill
David Hill el 16 de Feb. de 2022
Editada: David Hill el 16 de Feb. de 2022
So each row of 12 elements can only contain the elements [0 1 2] ? Are there any other contrains? How many times can each element be repeated in each row? Why don't you want to generate the matrix randomly?
A=[repmat([0 1 2],1,12)];
N=zeros(64,12,100);
for m=1:100
for k=1:100
M(k,:)=A(randperm(numel(A),12));
end
M=unique(M,'rows');
N(:,:,m)=M(1:64,:);
end
  5 comentarios
Shourya
Shourya el 15 de Mzo. de 2022
Hello David, I shall do that thank you for the solution!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear Algebra 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!

Translated by