0
$\begingroup$

I want to have a 4 tables with using of module. Unfortunately I don't know why doesn't it work

Do[Module[{m = n, i, j}, 
    tt[m_] := Table[i/11 + j/m, {i, 1, 5}, {j, 1, 5}], tt], {n, 9, 12}]

For each n I must have a 5*5 matrix of which elements are i/11 + j/m.

$\endgroup$

closed as off-topic by Jens, Sjoerd C. de Vries, Karsten 7., dr.blochwave, Mr.Wizard Jul 17 '15 at 9:05

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." – Jens, Sjoerd C. de Vries, Karsten 7., dr.blochwave, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Table[i/11 + j/m, {m, 9, 12}, {i, 5}, {j, 5}] will yield a list of your matrices. Note how the last three arguments are arranged. $\endgroup$ – J. M. will be back soon Jul 17 '15 at 5:18
  • $\begingroup$ Finally I must point to each 5*5 matrix as f[m_], for example f[m_] := Table[i/11 + j/m, {m, 9, 12}, {i, 5}, {j, 5}], but as you know it doesn't work correctly again. $\endgroup$ – Unbelievable Jul 17 '15 at 5:23
  • $\begingroup$ … *sigh* Table[f[m], {m, 9, 12}] = Table[(* stuff *)]. Probably important for you to know that we can do parallel assignment here: {x, y} = {2, 3} will set the two symbols to their corresponding values. $\endgroup$ – J. M. will be back soon Jul 17 '15 at 5:28
  • $\begingroup$ I have understood my mistake in my last comment. $\endgroup$ – Unbelievable Jul 17 '15 at 8:00
1
$\begingroup$

Summarizing J.M.'s comments you could use:

Do[
  f[m] = Table[i/11 + j/m, {i, 5}, {j, 5}],
  {m, 9, 12}
];

f[11] // MatrixForm

$\left( \begin{array}{ccccc} \frac{2}{11} & \frac{3}{11} & \frac{4}{11} & \frac{5}{11} & \frac{6}{11} \\ \frac{3}{11} & \frac{4}{11} & \frac{5}{11} & \frac{6}{11} & \frac{7}{11} \\ \frac{4}{11} & \frac{5}{11} & \frac{6}{11} & \frac{7}{11} & \frac{8}{11} \\ \frac{5}{11} & \frac{6}{11} & \frac{7}{11} & \frac{8}{11} & \frac{9}{11} \\ \frac{6}{11} & \frac{7}{11} & \frac{8}{11} & \frac{9}{11} & \frac{10}{11} \\ \end{array} \right)$

Also see Array, e.g.:

Do[
  f[m] = Array[#/11 + #2/m &, {5, 5}],
  {m, 9, 12}
];
$\endgroup$

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