Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: simple question about removing elements from a table

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122411] Re: simple question about removing elements from a table
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Thu, 27 Oct 2011 06:34:35 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201110262137.RAA29967@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

Here are three ways out of MANY:

data = {{-0.5, 0.0321787}, {-0.489, 0.0321691}, {-0.478,
     0.032211}, {-0.467, 0.0321723}, {-0.456, 0.0322448}, {-0.444,
     0.0321498}, {-0.433, 0.032132}, {-0.422, 0.0321804}, {-0.411,
     0.0322158}, {-0.4, 0.0320886}, {-0.233, 0.0320596}, {0.567,
     0.00286087}, {0.578, -0.00143633}, {0.589, -0.00592979}, {0.6, \
-0.0113609}};

DeleteCases[data, {_?Positive, _}]

{{-0.5, 0.0321787}, {-0.489, 0.0321691}, {-0.478, 0.032211}, {-0.467,
   0.0321723}, {-0.456, 0.0322448}, {-0.444, 0.0321498}, {-0.433,
   0.032132}, {-0.422, 0.0321804}, {-0.411, 0.0322158}, {-0.4,
   0.0320886}, {-0.233, 0.0320596}}

Cases[data, {_?NonPositive, _}]

{{-0.5, 0.0321787}, {-0.489, 0.0321691}, {-0.478, 0.032211}, {-0.467,
   0.0321723}, {-0.456, 0.0322448}, {-0.444, 0.0321498}, {-0.433,
   0.032132}, {-0.422, 0.0321804}, {-0.411, 0.0322158}, {-0.4,
   0.0320886}, {-0.233, 0.0320596}}

Select[data, First@# <= 0 &]

{{-0.5, 0.0321787}, {-0.489, 0.0321691}, {-0.478, 0.032211}, {-0.467,
   0.0321723}, {-0.456, 0.0322448}, {-0.444, 0.0321498}, {-0.433,
   0.032132}, {-0.422, 0.0321804}, {-0.411, 0.0322158}, {-0.4,
   0.0320886}, {-0.233, 0.0320596}}

Bobby

On Wed, 26 Oct 2011 16:37:09 -0500, Michael B. Heaney <mheaney at gmail.com>  
wrote:

> Hi,
>
> I have a data table:
>
> data={{-0.5, 0.0321787}, {-0.489, 0.0321691}, {-0.478,
> 0.032211}, {-0.467, 0.0321723}, {-0.456, 0.0322448}, {-0.444, 0.0321498},
> {-0.433, 0.032132}, {-0.422, 0.0321804}, {-0.411, 0.0322158},
> {-0.4, 0.0320886},  {-0.233,  0.0320596},  {0.567, 0.00286087}, {0.578,
> -0.00143633}, {0.589, -0.00592979}, {0.6, -0.0113609}}
> I want to remove all of the elements that have a positive first number,  
> to
> get:
>
> datasubset={{-0.5, 0.0321787}, {-0.489, 0.0321691}, {-0.478,
> 0.032211}, {-0.467, 0.0321723}, {-0.456, 0.0322448}, {-0.444, 0.0321498},
> {-0.433, 0.032132}, {-0.422, 0.0321804}, {-0.411, 0.0322158},
> {-0.4, 0.0320886},  {-0.233,  0.0320596}}
>
>  How do I do this?
>
> Thanks,
>
> Michael


-- 
DrMajorBob at yahoo.com



  • Prev by Date: Re: simple question about removing elements from a table
  • Next by Date: Re: Table to calculate faster
  • Previous by thread: Re: simple question about removing elements from a table
  • Next by thread: Re: simple question about removing elements from a table