[Numpy-discussion] Are there command similar as Matlab find command?
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:
<stdin>(1)<module>()> c:\dhg\docsis\lab_test\parseadc.py(70)parsempeg()-> bb=array(fid).astype('int')
It does not return any result.
Frank> Date: Mon, 29 Sep 2008 16:48:23 -0500> From: firstname.lastname@example.org> To: email@example.com> 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> Numpyfirstname.lastname@example.org> http://projects.scipy.org/mailman/listinfo/numpy-discussion
Want to do more with Windows Live? Learn “10 hidden secrets” from Jamie.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion