[Numpy-discussion] Selected and altering a submatrix

Keith Goodman kwgoodman at gmail.com
Mon Jan 29 23:46:32 EST 2007

On 1/29/07, Steve Lianoglou <lists.steve at arachnedesign.net> wrote:
> For example, say I have a 10x10 array and only want to add some
> number to the elements in the submatrix that consists of the [0,1,2]
> th rows, and [4,5,6]th colums.

Here's one way to do it:

i,j = N.mgrid[0:3,4:7]
mat[i,j] += 1

More information about the NumPy-Discussion mailing list