Hi Eric,
Here are ways of doing this.
starting with
import numpy as N

On 12/28/06, Eric Emsellem <[EMAIL PROTECTED]> wrote:

### Increasing order in x, and x1 <= x2 :
x = arange(0.,1.,0.1)
x1 = 0.1
x2 = 0.55
### the output I would like is simply: array([ 0.1, 0.2, 0.3, 0.4,
0.5])


How about this?
x=N.arange(0.,1.,0.1)
x[ (x>=0.1) & (x<=0.55) ]

### decreasing order in x, and x1 <= x2 :
x = arange(0.,-1.,-0.1)
x1 = -0.55
x2 = -0.1
### I would like is then: array([ -0.5, -0.4, -0.3, -0.2, -0.1])


x=N.arange(0.,-1.,-0.1)
N.sort( x[ (x<=-0.1) & (x>=-0.55) ] )
or
x[(x<=-0.1)&(x>=-0.55)][::-1]
just reverses the returned array.


### decreasing order in x, and x1 >= x2 :
x = arange(0.,-1.,-0.1)
x1 = -0.1
x2 = -0.55
### I would like is then: array([ -0.1, -0.2, -0.3, -0.4, -0.5])


x=N.arange(0.,-1.,-0.1)
x[ (x<=-0.1) & (x>=-0.55) ]


A few comments because I'm not totally clear on what you want to do.
(x<=-0.1)&(x>=-0.55)
will give you a boolean array of the same length as x
find((x<=-0.1)&(x>=-0.55))
will return the list of indices where the argument is true.

Regards,
Greg

--
Linux.  Because rebooting is for adding hardware.
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to