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

David Koch ogdude at googlemail.com
Thu Mar 15 07:26:10 EDT 2007


On 3/14/07, Gael Varoquaux <gael.varoquaux at 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://mail.python.org/pipermail/numpy-discussion/attachments/20070315/817d0cea/attachment.html>


More information about the NumPy-Discussion mailing list