tags:

views:

40

answers:

3

I am a pretty new to python. I have created an empty matrix

a = numpy.zeros(shape=(n,n))

Now I can access each element using

a.item(i,j)

How do I set an index (i,j)?

+6  A: 

Here's how:

a[i,j] = x
Can Berk Güder
+1  A: 

Try this

a[i,j]=5
gnibbler
+3  A: 

Or

a.itemset((i,j),x)
S.Mark