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


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

Re: simple question about removing elements from a table

From Tomas Garza <tgarza10@msn.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: simple question about removing elements from a table
Date 2011-10-27 10:33 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j8bc1l$8ni$1@smc.vnet.net> (permalink)
References <201110262137.RAA29967@smc.vnet.net>

Show all headers | View raw


Try
In[1]:= 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}};
In[2]:= DeleteCases[data, x_ /; x[[1]] > 0]
Out[2]= {{-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}}
-Tomas

> Date: Wed, 26 Oct 2011 17:37:09 -0400
> From: mheaney@gmail.com
> Subject: simple question about removing elements from a table
> To: mathgroup@smc.vnet.net
>
> 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
> --
> ------------------------------------------------------------
> Michael B. Heaney
> 3182 Stelling Drive
> Palo Alto, CA 94303 USA
> mheaney@alum.mit.edu
> www.linkedin.com/in/michaelbheaney
> ------------------------------------------------------------

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


Thread

Re: simple question about removing elements from a table Tomas Garza <tgarza10@msn.com> - 2011-10-27 10:33 +0000

csiph-web