# Create a list of indexed matrices and then change their entries

I make a list of 5 empty $3 \times 3$ matrices via

 Table[m[i]=IdentityMatrix[3]-IdentityMatrix[3],{i,1,5}]


However when I want to change an entry via

 m[2][[3,4]]=5


I get an error which reads:

Set::setps: m[2] in the part assignment is not a symbol. >>

Any ideas? Thanks

• Why not do something like m = ConstantArray[0, {5, 3, 3}] and then do m[[2, 3, 4]] = 1? – J. M. is away Mar 30 '17 at 5:37
• You mean instead of explicitly indexing the matrices, placing them in a list and identifying them there. That does make the way I call the matrices a little more intuitive, I don't have the single brackets and then the double brackets. However, I'm curious why indexing the matrices directly messes with the assignment I make. – Mike Mar 30 '17 at 5:40
• The docs for the error message just says "Part assignments are implemented only for parts of the value of a symbol." So since m[2] is not a symbol itself, but a reference to one of the DownValues of the symbol m, this is what you get. – Marius Ladegård Meyer Mar 30 '17 at 5:42
• Also, note the difference between Do and Table, we don't use Table just for side effects ;) – Marius Ladegård Meyer Mar 30 '17 at 5:43
• You can do e.g. m[2] = ReplacePart[m[2], {3, 4} -> 5] but that copies the whole of m[2] so I would prefer @J.M. 's suggestion. – Marius Ladegård Meyer Mar 30 '17 at 5:49

 m[2]=ReplacePart[m[2],{4,5}->5].