MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Position

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131134] Re: Position
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Fri, 14 Jun 2013 04:57:15 -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
  • References: <kpbp24$95n$1@smc.vnet.net>

On 13 Jun., 08:32, Costa Bravo <q13a2... 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

Not very elegant but it works:

In[52]:= t = RandomReal[{0, 5}, 10]

Out[52]= {3.6397213817178766, 4.7225642409045605, 1.3556422889069708,
\
2.9166466052152735, 1.9669329531284898, 4.151613177508343, \
0.5892783429281856, 4.990426012185576, 3.13226327938696, \
3.9424416959816426}

In[53]:= Flatten[(Position[t, #1] & ) /@ Select[t, #1 > 2 & ]]

Out[53]= {1, 2, 4, 6, 8, 9, 10}

Regards,
Wolfgang



  • Prev by Date: Re: Position
  • Next by Date: Re: Position
  • Previous by thread: Re: Position
  • Next by thread: Re: Position