|   | 1 |  initial version  | 
One possible solution is to construct/return not only a matrix but also a mapping (dict) of variables to their indices - like:
def symbolic_matrix(root,m,n):
    var2ind = {}
    mlist=[]
    for i in range(m):
        for j in range(n):
            var2ind[SR(root+'_'+str(i)+'_'+str(j))] = [i,j]
            mlist.append(root+'_'+str(i)+'_'+str(j))
    return Matrix(SR,m,n,mlist), var2ind
k,n=4,8
r1, v2i = symbolic_matrix('y',k,n)
v2i[r1[2,3]]
|   | 2 |  No.2 Revision  | 
One possible solution is to construct/return not only a matrix but also a mapping (dict) of variables to their indices - like:
def symbolic_matrix(root,m,n):
    var2ind = {}
    mlist=[]
    for i in range(m):
        for j in range(n):
            var2ind[SR(root+'_'+str(i)+'_'+str(j))] v = SR(root+'_'+str(i)+'_'+str(j))
            var2ind[v] = [i,j]
            mlist.append(root+'_'+str(i)+'_'+str(j))
mlist.append(v)
    return Matrix(SR,m,n,mlist), var2ind
k,n=4,8
r1, v2i = symbolic_matrix('y',k,n)
v2i[r1[2,3]]
 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.