1

How can I output a series of data, ranging from s00, s01, s02, s10, s11, s12, s20, s21, s22; by writing a table with s is a fixed, and m and n are running parameters, for example:

Table[ToString[smn], {m,0,2},{n,0,2}] ?

This above command fails, because it outputs something that I don't aim for:

{{0,0,0},{0,s,2 s},{0,2 s,4 s}}

but I wish to have an output like:

{{s00, s01, s02}, {s10, s11, s12}, {s20, s21, s22}}

So how should I modify my Table?

wonderich
  • 923
  • 1
  • 8
  • 14
  • 4
    wonderich, I think this question could be considered a duplicate of http://mathematica.stackexchange.com/q/20412/121 e.g. Table[ToString @ Row @ {s, m, n}, {m, 0, 2}, {n, 0, 2}]. Please let me know if you agree. – Mr.Wizard Dec 03 '16 at 06:45
  • 1
    In addition, smn is a single symbol. – Yves Klett Dec 03 '16 at 07:02
  • Thank you everyone, m_goldberg gives a much easier answer that seems to be appropriate for others to follow. So it is valuable to keep m_goldberg 's answer. – wonderich Dec 03 '16 at 16:18

1 Answers1

2

Two minor variations on your code will do it.

Table[StringJoin["s", ToString /@ {m, n}], {m, 0, 2}, {n, 0, 2}]

or

Table["s" <> ToString[m] <> ToString[n], {m, 0, 2}, {n, 0, 2}]

Both produce

{{"s00", "s01", "s02"}, {"s10", "s11", "s12"}, {"s20", "s21", "s22"}}

m_goldberg
  • 107,779
  • 16
  • 103
  • 257