[Numpy-discussion] Matlab -> NumPy translation and indexing
David Koch
ogdude@googlemail....
Mon Mar 5 07:13:02 CST 2007
Hello,
I am trying to translate some Matlab code to NumPy. I started reading the
NumPy book and, yeah it's a very long read :-/ One thing I am completely
confused about are the concpets of "basic" vs. "advanced" indexing. Are
there some good examples out there where for the same piece of code - Matlab
and NumPy are compared? I feel looking at those maybe more helpful to get me
started than an in-depth study of the book. I already read "Numpy for Matlab
users" and at a glance it doesn't seem to contain equivalents to all the
common indexing operations you'd do in Matlab.
Some concrete problems/questions I have right now:
- Am I correct in assuming that all arrays have to be initialized to their
final number of elements in NumPy (using empty/zero for instance)?
- Given a matrix R, is there an equvialent to the Matlab operation R(:,j) =
[] (which removes column j and "shrinks" the matrix?
- For (basic ?) indexing of an ndarray - is there any reason to prefer
A[i,j] over A[i][j]?
- Is it "pythonic" to initialize vectors to 2 dimensions so that
vec.shape== (len(vec), 1) instead of
vec.shape == (len(vec),)?
Alright,
Thanks for now,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070305/3f3a2943/attachment.html
More information about the Numpy-discussion
mailing list