[Numpy-discussion] Matlab -> NumPy translation and indexing

David Koch ogdude@googlemail....
Thu Mar 15 06:26:10 CDT 2007


On 3/14/07, Gael Varoquaux <gael.varoquaux@normalesup.org> wrote:
>
>
> I definitely second this comment. Using arrays when you are trying to
> append a lot of data is using the wrong data format. And the code is so
> much more readable with lists.


Thank you,

I will consider it,


Next thing, I have

A_Idx = array([1, 0])

and B is a matrix. How would I select the four elements in B indicated by
"meshgrid(A_Idx)", that ist: B[1,1], B[1,0], B[0,1], B[0,0]
In Matlab you would simply use B(A_idx, A_idx) whereas in NumPy B[A_Idx,
A_idx] returns B[1,1] and B[0,0] only.

I read that A.take(A_idx).take(A_idx, axis = 1) should work but it doesn't.

Thank you,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070315/817d0cea/attachment-0001.html 


More information about the Numpy-discussion mailing list