Script that create all combination in a matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I have a matrix of 3 elements (3 columns).
A | B | C
Each elements can take 4 values (0, 1, 2, 3). Is there a function or a way to test all possibilities and complete the matrix with all possibilities ? So 3^4 possibilities.
0|1|2
0|1|3
...
...
Thanks
Edit : I miss an information, in my case elements can have same values so i need to take in consideration :
0 | 0 | 0
1 | 1 | 1
0 | 0 | 2
...
댓글 수: 2
채택된 답변
Rik
2020년 6월 19일
Yet another possible solution:
A=0:3;B=0:3;C=0:3;
[A_,B_,C_]=ndgrid(A,B,C);
combs=[A_(:),B_(:),C_(:)];
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!