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

Neilen Marais nmarais at sun.ac.za
Tue May 20 11:06:09 EDT 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