2010-02-08 9 views
16

Je suis un peu nouveau sur python. J'ai créé une matrice videPython: Définition d'un élément d'une matrice Numpy

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

Maintenant, je peux accéder à chaque élément à l'aide

a.item(i,j) 

Comment puis-je configurer un index (i, j)?

+2

tutoriel Numpy (http://www.scipy.org/Tentative_NumPy_Tutorial#head-4c1d53fe504adc97baf27b65513b4b97586a4fc5), section 3.5 – telliott99

Répondre

45

Voilà comment:

a[i,j] = x 
1

Essayez cette

a[i,j]=5 
8

Ou

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