MathGroup Archive 2007

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

Search the Archive

Re: AW: position of matrix elements for intervals

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78506] Re: AW: position of matrix elements for intervals
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 3 Jul 2007 05:31:46 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <f6alhs$hld$1@smc.vnet.net>

Kristoph Steikert wrote:
> Thanks a lot, this was helpful! But it seems that I have an extended problem
> and I would kindly ask for your help.
> Do you have an idea how to allocate the position of the first element
> satisfying the condition of each column from below?
> 
> Example:
> data = {{1, 1.`, 0.9999999932328848`}, {1.`, 0.9985849617864345`,
>     3.7570598417296495`*^-108}, {0.9999999999267634`,
>     4.0643593704937925`*^-207, 0}};
> 
> I'm looking for the position from below of the first element in each column
> meeting #>=0.99.
> 
> The output should be:
> {{1,3},{2,2},{3,1}}
> 
> 
> I appreciate your help very much,
> Kristoph
> 
> 
> 
> -----Urspr=FCngliche Nachricht-----
> Von: hanlonr at cox.net [mailto:hanlonr at cox.net]
> Gesendet: Sonntag, 1. Juli 2007 17:05
> An: kristoph; mathgroup at smc.vnet.net
> Betreff: Re:  position of matrix elements for intervals
> 
> data = {{1, 1.`, 0.9999999932328848`}, {1.`, 0.9985849617864345`,
>     3.7570598417296495`*^-108}, {0.9999999999267634`,
>     4.0643593704937925`*^-207, 0}};
> 
> The second argument to Position must be written as a pattern:
> 
> Position[data, _?(# >= 0.99 &)]
> 
> {{1, 1}, {1, 2}, {1, 3}, {2, 1},
>    {2, 2}, {3, 1}}
> 
> Position[data, _?(0.4 <= # <= 0.9999 &)]
> 
> {{2, 2}}
> 
> 
> Bob Hanlon
> 
> ---- kristoph <kristophs.post at web.de> wrote:
>> Hi,
>>
>> Assume you have the following table:
>>
>> {{1, 1.`, 0.9999999932328848`}, {1.`, 0.9985849617864345`,
>>       3.7570598417296495`*^-108}, {0.9999999999267634`,
>>       4.0643593704937925`*^-207, 0}}
>>
>> I would like the position of all the elements >= 0.99. Or the position
>> of all the elements of [0.4, 0.9] which in the above table does make a
>> lot of sense.
>> I'm familiar with Position[...,.] but since I look for reals of an
>> interval I would kindly ask for help.
>>
>> Thanks a lot,
>> Kristoph

One way of doing it is the following:

In[1]:= data = {{1, 1., 0.9999999932328848}, {1.,
     0.9985849617864345,
          3.7570598417296495*^-108}, {0.9999999999267634,
          4.0643593704937925*^-207, 0}};

Last /@ Split[Position[data, _?(#1 >= 0.99 & )],
      First[#1] === First[#2] & ]

Last /@ Split[Position[data, _?(0.4 <= #1 <= 0.9999 & )],
      First[#1] === First[#2] & ]

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

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

Regards,
Jean-Marc


  • Prev by Date: Re: Re: problem with Pick
  • Next by Date: Re: Rotable Graphics and ViewPoint
  • Previous by thread: Re: AW: position of matrix elements for intervals
  • Next by thread: Re: AW: position of matrix elements for intervals