0
$\begingroup$

I'm just trying to set up a Matrix 24 by 24 with indices that start from 0 to 23

Array[t, {24, 24}, {0, 0}];
Do[t[k, j] = k + j, {k, 0, 23}, {j, 0, 23}];
t[1, 1] // MatrixForm
MatrixForm[t]

Everything seems fine but when I'd like to have the output in matrixForm the result is simply t ( https://gyazo.com/312ac29c839ca63b831a3e22423f5571 )

Does anybody knows why?

$\endgroup$
3
  • 2
    $\begingroup$ Clear[t] t = Array[#1 + #2 &, {24, 24}, {0, 0}]; Dimensions@t and finally t // MatrixForm $\endgroup$
    – Syed
    Commented Mar 30, 2022 at 8:01
  • 3
    $\begingroup$ in Array the t is the entries. You might want to do ClearAll[t]; T0 = Array[t, {24, 24}, {0, 0}]; Do[t[k, j] = k + j, {k, 0, 23}, {j, 0, 23}]; MatrixForm[T0]; $\endgroup$
    – Nasser
    Commented Mar 30, 2022 at 8:01
  • 1
    $\begingroup$ Also check Table. It is the most natural way, in Mathematica, to create the matrix you want. $\endgroup$ Commented Mar 30, 2022 at 14:05

1 Answer 1

2
$\begingroup$

Try this:

Do[t = Array[s, {24, 24}, {0, 0}]; s[k, j] = k + j, {k, 0, 23}, {j, 0, 23}]
MatrixForm@t

enter image description here

$\endgroup$

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