Re: first and last index as in matlab

2006-12-18 Thread Evan
Thanks for all the replies, it's much clearer now. -Evan -- http://mail.python.org/mailman/listinfo/python-list

Re: first and last index as in matlab

2006-12-17 Thread sturlamolden
It's quite straight forward, actually. What you need to know is that -1 is the index of the last element in a sequence, and that slicing excludes the 'end' value in 'start:end'. So if you type arr[0:N], you get the subsequence [arr[0], arr[1], arr[2], ..., arr[N-1]] When comparing with Matlab, P

Re: first and last index as in matlab

2006-12-17 Thread Robert Kern
Beliavsky wrote: > Evan wrote: >> In matlab I can do the following: >> ind = [3,5,7,2,4,7,8,24] >> ind = 3 5 7 2 4 7 824 ind(1) ans = 3 ind(end) ans =24 ind([1 end]) ans = 324 >> but I can't get the last line in python:

Re: first and last index as in matlab

2006-12-17 Thread Beliavsky
Evan wrote: > In matlab I can do the following: > > >> ind = [3,5,7,2,4,7,8,24] > ind = 3 5 7 2 4 7 824 > >> ind(1) ans = 3 > >> ind(end) ans =24 > >> ind([1 end]) ans = 324 > > but I can't get the last line in python: > > In [690]: ind =

Re: first and last index as in matlab

2006-12-17 Thread Paul McGuire
"Evan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In matlab I can do the following: > >>> ind = [3,5,7,2,4,7,8,24] > ind = 3 5 7 2 4 7 824 >>> ind(1) ans = 3 >>> ind(end) ans =24 >>> ind([1 end]) ans = 324 > > but I can'

Re: first and last index as in matlab

2006-12-17 Thread Rob Williscroft
Evan wrote in news:[EMAIL PROTECTED] in comp.lang.python: > In matlab I can do the following: > >>> ind = [3,5,7,2,4,7,8,24] > ind = 3 5 7 2 4 7 824 >>> ind(1) ans = 3 >>> ind(end) ans =24 >>> ind([1 end]) ans = 324 > > but I can't get

first and last index as in matlab

2006-12-17 Thread Evan
In matlab I can do the following: >> ind = [3,5,7,2,4,7,8,24] ind = 3 5 7 2 4 7 824 >> ind(1) ans = 3 >> ind(end) ans =24 >> ind([1 end]) ans = 324 but I can't get the last line in python: In [690]: ind = [3,5,7,2,4,7,8,24] In [691]: ind