How to generate all possible matrices with the given entries?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have 9 different entries (11,12,13,21,22,23,31,32,33). I want to generate all possible 3 by 3 matrices consisting of these entries with the condition that there is no repetition of any entry in any row and in any column. In short, all the 9 entries in each possible 3 by 3 matrix should be different.
답변 (1개)
KSSV
2018년 1월 26일
val = [11,12,13,21,22,23,31,32,33] ;
A = perms(val) ;
iwant = zeros(3,3,size(A,1)) ;
for i = 1:size(A,1)
iwant(:,:,i) = reshape(A(i,:),3,3) ;
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!