[Numpy-discussion] Are there command similar as Matlab find command?

frank wang f.yw@hotmail....
Mon Sep 29 20:16:14 CDT 2008


Thanks for the help. 
 
It seems that the where command has problem when I tried to run it in the debug mode. It does not return any thing such as:
 
(Pdb) aa=array([1,2,3,4]
(Pdb) where(aa>2)
  <stdin>(1)<module>()> c:\dhg\docsis\lab_test\parseadc.py(70)parsempeg()-> bb=array(fid).astype('int')
(Pdb)
 
It does not return any result. 
 
Frank> Date: Mon, 29 Sep 2008 16:48:23 -0500> From: oliphant@enthought.com> To: numpy-discussion@scipy.org> Subject: Re: [Numpy-discussion] Are there command similar as Matlab find command?> > frank wang wrote:> > Hi,> > > > I am trying to find a command in numpy or python that perform similar > > function as Matlab find command. It will return the indexes of array > > that satisfy a condition. So far I have not found anything.> > There are several ways to do this, but what are you trying to do? > Non-zero on the boolean array resulting from the condition is the most > direct way:> > (a>30).nonzero()> where(a>30)> > This returns a tuple of indices of length nd, where nd is the number of > dimensions of a. (i.e. for 1-d case you need to extract the first > element of the tuple to get the indices you want).> > But, if you are going to use these indices to access elements of the > array, there are better ways to do that:> > a[a>30]> compress(a>30, a)> > etc.> > -Travis> > _______________________________________________> Numpy-discussion mailing list> Numpy-discussion@scipy.org> http://projects.scipy.org/mailman/listinfo/numpy-discussion
_________________________________________________________________
Want to do more with Windows Live? Learn “10 hidden secrets” from Jamie.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080929/6fe01591/attachment-0001.html 


More information about the Numpy-discussion mailing list