[SciPy-user] extracting elements of a matrix using arrays as indices

Neilen Marais nmarais@sun.ac...
Tue May 20 10:06:09 CDT 2008


Hi Mike

On Tue, 20 May 2008 08:03:36 -0600, Michael Hearne wrote:

> In Python:
> a = array([[ 11, 12, 13, 14 ],
> [ 21, 22, 23, 24 ],
> [ 31, 32, 33, 34 ]])
> 
> a[[0,2],[0,3]]
> 
> gives you:
> 
> array([11, 34])

I think you're looking for 

a[ix_([0,2], [0,3])]  

ix_  == numpy.ix_

Regards
Neilen




More information about the SciPy-user mailing list