Re: Position
- To: mathgroup at smc.vnet.net
- Subject: [mg131152] Re: Position
- From: Ray Koopman <koopman at sfu.ca>
- Date: Fri, 14 Jun 2013 05:03:16 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
Length[t = RandomReal[{0, 5}, 10^6]]
1000000
AbsoluteTiming@Length[p = Position[t, _?(# > 2 &)]]
{4.348019, 599993}
AbsoluteTiming@Length[q = Pick[Range@Length@t, UnitStep[t - 2], 1]]
{0.716786, 599993}
Flatten@p === q
True
----- Costa Bravo <q13a27tt at aol.com> wrote:
> How can I find the indices of all elements greaters than e.g. 2 of a vector.
>
> t=RandomReal[{0,5},100]
> Position[t,??]
>
> --
> Costa