Build a Relation Between Matrix Elements
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a complex valued matrix for example:
a = complex(1.1,-1.3); b = complex(1.3,1.2);c = complex(1.5,-1.4); d = complex(1.8,1.2); % random numbers
A = [a b; c d];
How can I build a relation between the elements of the matrix as, and then get the sume for each element. All the relations would be calculated as:
A1_1 = A(1) + A(2) + A(3) + A(4);
A1_2 = A(1) + A(2) + A(3) - A(4);
A1_3 = A(1) + A(2) - A(3) + A(4);
A1_4 = A(1) - A(2) + A(3) - A(4);
A1_5 = A(1) + A(2) - A(3) - A(4);
A1_6 = A(1) - A(2) - A(3) + A(4);
A1_7 = A(1) - A(2) + A(3) + A(4);
A1_8 = A(1) - A(2) - A(3) - A(4);
A2_1 = A(2) + A(3) + A(4) + A(1);
A2_2 = A(2) + A(3) + A(4) - A(1);
A2_3 = A(2) + A(3) - A(4) + A(1);
A2_4 = A(2) - A(3) + A(4) - A(1);
A2_5 = A(2) + A(3) - A(4) - A(1);
A2_6 = A(2) - A(3) - A(4) + A(1);
A2_7 = A(2) - A(3) + A(4) + A(1);
A2_8 = A(2) - A(3) - A(4) - A(1);
A3_1 = A(3) + A(4) + A(1) + A(2);
A3_2 = A(3) + A(4) + A(1) - A(2);
A3_3 = A(3) + A(4) - A(1) + A(2);
A3_4 = A(3) - A(4) + A(1) - A(2);
A3_5 = A(3) + A(4) - A(1) - A(2);
A3_6 = A(3) - A(4) - A(1) + A(2);
A3_7 = A(3) - A(4) + A(1) + A(2);
A3_8 = A(3) - A(4) - A(1) - A(2);
A4_1 = A(4) + A(3) + A(2) + A(1);
A4_2 = A(4) + A(3) + A(2) - A(1);
A4_3 = A(4) + A(3) - A(2) + A(1);
A4_4 = A(4) - A(3) + A(2) - A(1);
A4_5 = A(4) + A(3) - A(2) - A(1);
A4_6 = A(4) - A(3) - A(2) + A(1);
A4_7 = A(4) - A(3) + A(2) + A(1);
A4_8 = A(4) - A(3) - A(2) - A(1);
A1 = A1_1 + A1_2 + A1_3 + A1_4 + A1_5 + A1_6 + A1_7 + A1_8
A2 = A2_1 + A2_2 + A2_3 + A2_4 + A2_5 + A2_6 + A2_7 + A2_8
A3 = A3_1 + A3_2 + A3_3 + A3_4 + A3_5 + A3_6 + A3_7 + A3_8
A4 = A4_1 + A4_2 + A4_3 + A4_4 + A4_5 + A4_6 + A4_7 + A4_8
ANew = [A1 A2; A3 A4]
4 Commenti
Risposta accettata
Voss
il 2 Giu 2022
Modificato: Voss
il 2 Giu 2022
If that's really what you want to do, notice that if you sum these 8 equations:
A1_1 = A(1) + A(2) + A(3) + A(4);
A1_2 = A(1) + A(2) + A(3) - A(4);
A1_3 = A(1) + A(2) - A(3) + A(4);
A1_4 = A(1) - A(2) + A(3) - A(4);
A1_5 = A(1) + A(2) - A(3) - A(4);
A1_6 = A(1) - A(2) - A(3) + A(4);
A1_7 = A(1) - A(2) + A(3) + A(4);
A1_8 = A(1) - A(2) - A(3) - A(4);
You get A1_1+A1_2+...+A1_8 = 8*A(1)
That's because all the A(2), A(3), and A(4) terms on the right-hand side add to zero. That is, there are 4 positive copies and 4 negative copies of each of A(2), A(3), A(4), so their sum is 0.
Therefore, the end result you're after is:
ANew = 8*A
(I think you have it transposed in the question, i.e., it should be ANew = [A1 A3; A2 A4]; that is, A2 comes from A(2), which is c, not b.)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!