Build a Relation Between Matrix Elements

1 view (last 30 days)
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
A1 = 8.8000 - 10.4000i
A2 = A2_1 + A2_2 + A2_3 + A2_4 + A2_5 + A2_6 + A2_7 + A2_8
A2 = 12.0000 - 11.2000i
A3 = A3_1 + A3_2 + A3_3 + A3_4 + A3_5 + A3_6 + A3_7 + A3_8
A3 = 10.4000 + 9.6000i
A4 = A4_1 + A4_2 + A4_3 + A4_4 + A4_5 + A4_6 + A4_7 + A4_8
A4 = 14.4000 + 9.6000i
ANew = [A1 A2; A3 A4]
ANew =
8.8000 -10.4000i 12.0000 -11.2000i 10.4000 + 9.6000i 14.4000 + 9.6000i
  4 Comments
MarshallSc
MarshallSc on 1 Jun 2022
I edited the original post with detailed calculation.

Sign in to comment.

Accepted Answer

Voss
Voss on 2 Jun 2022
Edited: Voss on 2 Jun 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.)
  2 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by