Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have got few huge matrices named by ascending numbers, e.g. x1, x2, x3,... and I need to do the same operation with all of them - to multiply their components, obtain the absolute value etc. As I am beginner with Mathematica I usually copy the expression and rewrite indexes as x1 -> x2, but this is very lengthy. I would like to have only one expression with something like xX, where I just change X by index of particular matrix.

share|improve this question
related: 33184 – Kuba Jun 18 '14 at 8:54
f @ Symbol["x" <> ToString[#]] & /@ Range[10]
{f[x1], f[x2], f[x3], f[x4], f[x5], f[x6], f[x7], f[x8], f[x9], f[x10]}


x1 = RandomReal[{-1, 1}, {5, 5}];
x2 = RandomReal[{-1, 1}, {5, 5}];

  Symbol["x" <> ToString[#]] &

  ] /@ Range[2]
share|improve this answer

Less sophisticated approach. The ?? at the end shows that Mathematica knows about these eight symbols. If I click on the "light blue" A1 in the Global` symbol table that appears in my notebook after entering ??Global`A*, the 16 elements of A1 are shown as a list of lists.

    In[1]:= Table[Symbol["A" <> ToString[i]], {i, 8}]

    Out[1]= {A1, A2, A3, A4, A5, A6, A7, A8}

    (* All of the symbols in the above list can be set to have numerical values *)

    (* and manipulated as usual.  For example: *)

    In[2]:= A1 = RandomReal[{-10.0, 10.0}, {4, 4}]

    Out[2]= {{-5.5598, 9.8372, -0.700913, 2.89629}, 
             {-6.42822, 1.26682, -7.52955, 3.2075},
             {0.28862, -7.03238, 0.366672, 9.61496}, 
             {6.60329, -8.92156, -8.83749, -7.38917}}

    In[3]:= A1.Inverse[A1] // Chop

    Out[3]= {{1., 0, 0, 0}, 
             {0, 1., 0, 0}, 
             {0, 0, 1., 0},
             {0, 0, 0, 1.}}

    In[4]:= ?? Global`A*

        A1   A2   A3   A4   A5   A6   A7   A8

But I guess I'm not answering your question. Sorry.

share|improve this answer
Dear user15996, we are very glad you found the site. Thank you for your contribution. Unfortunately I can't see how this answers the question. – Verbeia Jun 18 '14 at 11:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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