[SciPy-user] creating an array with changing resolution

Eike Welk eike.welk@gmx....
Sat May 30 06:32:56 CDT 2009


On Saturday 30 May 2009, Oz Nahum wrote:
> In octave,  I can define a vector like:
>
> v = [1:1:40,40:0.1:50,50:1:100]
>
> is this the only way to do it in numpy ?
> v = numpy.r_[arange(0.0,40.0, 1),arange(40.0,50.0,
> 0.1),arange(50.0,100.0, 1)]

You can also write:
In [30]:r_[1:10:3, 10:20:2]
Out[30]:array([ 1,  4,  7, 10, 12, 14, 16, 18])

HTH,
Eike.


More information about the SciPy-user mailing list