Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14839

Re: Position

From "Alexander Elkins" <alexander_elkins@hotmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Position
Date 2013-06-14 08:45 +0000
Message-ID <kpel6p$hpv$1@smc.vnet.net> (permalink)
References <kpbp24$95n$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Use Condition(/;) on a Pattern named x matching any Real to test x for
Greater than 2.0 like so:

In[1]:=
Position[{1.4,3.5,2.1,-1.2},x_Real/;x>2.]

Out[1]=
{{2},{3}}

In[2]:=
FullForm[x_Real /; x > 2.]

Out[2]=
Condition[Pattern[x, Blank[Real]], Greater[x, 2.`]]

Or use PatternTest on an unnamed pattern matching any Real to test it for
Greater than 2.0 like so:

In[3]:=
Position[{1.4,3.5,2.1,-1.2},_Real?(#>2.&)]

Out[3]=
{{2},{3}}

In[4]:=
FullForm[_Real?(#>2.&)]

Out[4]//FullForm=
PatternTest[Blank[Real],Function[Greater[Slot[1],2.`]]]

"Costa Bravo" <q13a27tt@aol.com> wrote in message
news:kpbp24$95n$1@smc.vnet.net...
> 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
>


Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Position Costa Bravo <q13a27tt@aol.com> - 2013-06-13 06:32 +0000
  Re: Position "Alexander Elkins" <alexander_elkins@hotmail.com> - 2013-06-14 08:45 +0000
  Re: Position "Dr. Wolfgang Hintze" <weh@snafu.de> - 2013-06-14 08:46 +0000
  Re: Position Helen Read <readhpr@gmail.com> - 2013-06-14 08:53 +0000
  Re: Position David Bailey <dave@removedbailey.co.uk> - 2013-06-15 08:17 +0000

csiph-web