开发者

Python: Setting an element of a Numpy matrix

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)

Ho开发者_如何学JAVAw do I set an index (i,j)?


Here's how:

a[i,j] = x


Or

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


Try this

a[i,j]=5
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜