All combinations of matrix elements?
이전 댓글 표시
Hello,
I'd like to find all combinations of 2 elements in a matrix.
For example, a = [1:4; 5:8; 9:12]', the result should be [1*1 1*2 1*3 1*4 1*5 ... 1*12 2*2 2*3 ... 2*12 3*3 ... 12*11 12*12]';
Thanks for your help!
댓글 수: 1
Stephen23
2016년 9월 26일
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2016년 9월 23일
편집: Andrei Bobrov
2016년 9월 23일
b = a(:)*a(:).';
out = b(tril(true(size(b))));
카테고리
도움말 센터 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!