Generating combination of matrix with 3 elements
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
Respuesta aceptada
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
Más respuestas (0)
Ver también
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!