2010-02-08 9 views
16

Soy bastante nuevo en Python. He creado una matriz vacíaPython: configuración de un elemento de una matriz Numpy

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

Ahora puedo acceder a cada elemento utilizando

a.item(i,j) 

¿Cómo se configura un índice (i, j)?

+2

Numpy tutorial (http://www.scipy.org/Tentative_NumPy_Tutorial#head-4c1d53fe504adc97baf27b65513b4b97586a4fc5), sección 3.5 – telliott99

Respuesta

45

Así es como:

a[i,j] = x 
1

probar este

a[i,j]=5 
8

O

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