Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can I add the Matrices created by this:

SeedRandom@0;
Table[RandomInteger[{0, 34}, {2, 2}], {2}, {5}] // MatrixForm

$\left( \begin{array}{ccccc} \left( \begin{array}{cc} 32 & 33 \\ 22 & 15 \\ \end{array} \right) & \left( \begin{array}{cc} 3 & 30 \\ 34 & 4 \\ \end{array} \right) & \left( \begin{array}{cc} 14 & 24 \\ 28 & 10 \\ \end{array} \right) & \left( \begin{array}{cc} 10 & 12 \\ 21 & 31 \\ \end{array} \right) & \left( \begin{array}{cc} 33 & 5 \\ 15 & 0 \\ \end{array} \right) \\ \left( \begin{array}{cc} 9 & 13 \\ 22 & 31 \\ \end{array} \right) & \left( \begin{array}{cc} 26 & 22 \\ 1 & 9 \\ \end{array} \right) & \left( \begin{array}{cc} 31 & 15 \\ 28 & 13 \\ \end{array} \right) & \left( \begin{array}{cc} 27 & 15 \\ 16 & 8 \\ \end{array} \right) & \left( \begin{array}{cc} 23 & 13 \\ 33 & 25 \\ \end{array} \right) \\ \end{array} \right)$

share|improve this question

closed as off-topic by Öskå, bobthechemist, rasher, m_goldberg, Jens Jun 24 at 3:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Öskå, bobthechemist, rasher, m_goldberg, Jens
If this question can be reworded to fit the rules in the help center, please edit the question.

    
What do you mean by add? Add every matrices of each row? Each collumns? All of them? –  Öskå Jun 23 at 17:57
    
Adding all of them.. –  Irah Idebus Jun 23 at 17:58

2 Answers 2

up vote 3 down vote accepted
SeedRandom@0;
m = Table[RandomInteger[{0, 34}, {2, 2}], {2}, {5}];
Total@Flatten[m, 1]

$\left( \begin{array}{cc} 208 & 182 \\ 220 & 146 \\ \end{array} \right)$

share|improve this answer
SeedRandom@0;
m = Table[RandomInteger[{0, 34}, {2, 2}], {2}, {5}];

Total[m, 2]   (* total all elements down to level 2 *)
(* {{208, 182}, {220, 146}} *)
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.