[Numpy-discussion] Matlab page on scipy wiki

Bill Baxter wbaxter at gmail.com
Thu Mar 2 20:48:01 EST 2006


Ah, right you are.  Fixed.  Thanks.
I guess the python version could also be written a[:5].

--bb

On 3/3/06, Sebastian Haase <haase at msg.ucsf.edu> wrote:
>
> Hi,
> I noted on
> http://www.scipy.org/Wiki/NumPy_for_Matlab_Users
>
> matlab  a(1:5,:)
> numpy  a[0:4] or a[0:4,:]  a[0:4] or  a[0:4,:]
> the first five rows of a
>
> I think this is wrong!
>
> in numpy it would be: a[:5] (or a[0:5] )  for the first five elements
>
> To the best of my knowledge (I have never used Matlab myself!) this is
> one of the biggest points of confusion for Matlab users !!
> WHY DOES a[4:6] NOT INCLUDE THE ELEMENTS 4,5 *AND* 6 ???
>
> The only explanation I have is that its
> a) like a C/C++-for-loop (for(i=4;i<6;i++)   --> note the '<'  (not '<=')
> b) it then also always is true that: "last" minus first is equal to
> number-of-elements (example: 6-4 = 2)
> c) it turns out from experience that this convention WILL save you lots
> of '-1' and '+1' in your code (actually almost all of them)
> [if I see a "+1" in a Matlab person's numpy code I can almost always
> guess that he/she made a mistake !]
>
> Maybe this paragraph could be added to the wiki ...
>
> Thanks for this wiki page - I think I looks great
>
> - Sebastian Haase
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>



--
William V. Baxter III
OLM Digital
Kono Dens Building Rm 302
1-8-8 Wakabayashi Setagaya-ku
Tokyo, Japan  154-0023
+81 (3) 3422-3380
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060302/368c59e7/attachment.html>


More information about the NumPy-Discussion mailing list