All combinations of matrix elements?
Ältere Kommentare anzeigen
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!
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 23 Sep. 2016
Bearbeitet: Andrei Bobrov
am 23 Sep. 2016
b = a(:)*a(:).';
out = b(tril(true(size(b))));
1 Kommentar
Xiaohan Du
am 23 Sep. 2016
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!