How can I generate a set containing all possible combinations?
조회 수: 5 (최근 30일)
이전 댓글 표시
Let say I want to have a 2x2 matrix and the entries are chosen from numbers 1-8 (without repetition).
How can I generate a set that contains all the possible matrices? Thanks a lot!
댓글 수: 0
답변 (2개)
Bruno Luong
2019년 3월 28일
편집: Bruno Luong
2019년 3월 28일
A = nchoosek(1:8,4);
A = num2cell(reshape(A',2,2,[]),[1 2]);
A = A(:);
% display
A{:}
Produces 70 2x2 matrices
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!