21 Jan
2005
21 Jan
'05
3:37 p.m.
Chris Barker wrote:
Simon Burton wrote:
On Thu, 20 Jan 2005 20:29:26 -0500 Yun Mao
wrote: 2. Is there a way to do Matlab style slicing? e.g. if I have i = array([0, 2]) x = array([1.1, 2.2, 3.3, 4.4]) I wish y = x(i) would give me [1.1, 3.3]
have a look at the "take" method.
or use numarray:
import numarray as N i = N.array([0, 2]) x = N.array([1.1, 2.2, 3.3, 4.4]) y = x[i] y array([ 1.1, 3.3])
Or use scipy: from scipy import * alter_numeric() i = array([0,2]) x = array([1.1,2.2,3.3,4.4]) y = x[i] print y [1.1 3.3]