We have a nested matrix
m1 = {{{1, 2, 2, I}, {1, 1, -2, 1}, {3, 2, 2, -I}}, {{3, 4, 4, I}, {1, 1, 4, 1}, {3, 3, 4, -1}}};
we must replace the first number of each sub_list with the third number and vise versa and and achieve to m2
as:
m2 = {{{2, 2, 1, I}, {-2, 1, 1, 1}, {2, 2, 3, -I}}, {{4, 4, 3, I}, {4, 1, 1, 1}, {4, 3, 3, -1}}};
The shape of m1
and m2
are as below. We know that we can use of two loops with an IF
condition but we don't think it is a good way. If Possible please let us know how can we obtain m2
?
m1:
m2: