How to use Table to create 3x3 Matrix in Mathematica

时间:2017-06-09 12:55:27

标签: matrix wolfram-mathematica

I use the table function to create a 3x3 matrix in index notation. I assume that I can access the element in first row and first column using A[[1,1]] but instead I need to use A[[1,1,1]]. How can I define a 3x3 matrix so that I can access each element by using A[[rowNum,colNum]] notation? Please see code below:

ClearAll["Global`*"]
A = Table[Subscript[a, i, j], {i, 1, 3}, {j, 1, 3}] // MatrixForm
A[[1, 1]]
A = {{Subscript[a, 1, 1], Subscript[a, 1, 2], 
    Subscript[a, 1, 3]}, {Subscript[a, 2, 1], Subscript[a, 2, 2], 
    Subscript[a, 2, 3]}, {Subscript[a, 3, 1], Subscript[a, 3, 2], 
    Subscript[a, 3, 3]}} // MatrixForm
A[[1, 1]]

1 个答案:

答案 0 :(得分:0)

// MatrixForm的定义中删除A,原因是MatrixForm与大多数*Form函数基本上都是格式化函数。为了计算事物,保持所有初始变量保持输入数据和中间变量可计算,并且只在结束时格式化。如上所述,A的最外面的函数头是MatrixForm,因此A[[1]]而不是A是您可能想要的可计算矩阵值。