Automatically populating matrix elements in SymPy

Viewed 3362

Is there a way to implicitly define the elements of a symbolic matrix in SymPy following a rule such as: symbol followed by subindices in the matrix (or pairs of numbers)

For example, I would like to define a 3 x 2 matrix called M, and I would like SymPy to automatically create it and populate it as:

M = 
[ M_11 M_12]
[ M_21 M_22]
[ M_31 M_32]

If there is no way to do this implicitly, what would be the easiest way to do this explicitly (e.g. looping)?

2 Answers
Related