Filter löschen
Filter löschen

On a symmetrical matrix how do you calculate the sum of every possible combination of 3 elements ?

2 Ansichten (letzte 30 Tage)
I have a 10X10 Symmetrical Matrix, Where the Columns and Rows are both S1 to S10 shown below,
What I need is a code that will get me the sum of every possible combination of 3, example: S3,S4,S8 = sum of S3S4 ,S3S8, S4S8

Antworten (1)

Walter Roberson
Walter Roberson am 12 Feb. 2016
M = dec2bin(0:2^10-1,10) - '0';
mask = sum(M,2) == 3;
M = M(mask,:);
sums = M * S;
  1 Kommentar
Walter Roberson
Walter Roberson am 13 Feb. 2016
By the way, my estimate is that this is cost-effective up to roughly 22 elements in the original matrix, after which the memory requirements slow it too much. There are other ways to write it that would use less memory.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by