MathGroup Archive 2009

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

Search the Archive

Re: put some elements to zero

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101483] Re: [mg101438] put some elements to zero
  • From: Adriano Pascoletti <adriano.pascoletti at dimi.uniud.it>
  • Date: Wed, 8 Jul 2009 07:12:32 -0400 (EDT)
  • References: <200907071146.HAA27467@smc.vnet.net>

In[4]:= L = {{4, 7}, {2, 5}, {3, 5}, {3, 0}, {10, 2}, {8, 7}, {1, 8}, {2,
3},
       {5, 8}, {4, 2}, {2, 6}, {9, 8}, {0, 6}, {8, 5}, {8, 9}, {3, 4},
       {2, 8}, {6, 8}, {2, 9}, {2, 10}, {9, 9}, {10, 7}, {6, 4}, {10, 8},
       {7, 2}, {5, 0}, {8, 4}, {5, 10}, {2, 5}, {4, 0}, {6, 4}, {0, 5},
       {8, 4}, {10, 4}, {6, 2}, {5, 4}, {2, 4}, {3, 3}, {6, 5}, {8, 4},
       {1, 3}, {1, 2}, {10, 6}, {10, 6}, {0, 1}, {0, 2}, {0, 5}, {1, 0},
       {2, 7}, {3, 6}};
x0 = 5;
L /. {x_ /; x < x0, y_} :> {x, 0}
Out[6]= {{4, 0}, {2, 0}, {3, 0}, {3, 0}, {10, 2}, {8, 7}, {1, 0}, {2, 0},
   {5, 8}, {4, 0}, {2, 0}, {9, 8}, {0, 0}, {8, 5}, {8, 9}, {3, 0},
   {2, 0}, {6, 8}, {2, 0}, {2, 0}, {9, 9}, {10, 7}, {6, 4}, {10, 8},
   {7, 2}, {5, 0}, {8, 4}, {5, 10}, {2, 0}, {4, 0}, {6, 4}, {0, 0},
   {8, 4}, {10, 4}, {6, 2}, {5, 4}, {2, 0}, {3, 0}, {6, 5}, {8, 4},
   {1, 0}, {1, 0}, {10, 6}, {10, 6}, {0, 0}, {0, 0}, {0, 0}, {1, 0},
   {2, 0}, {3, 0}}


Adriano Pascoletti

2009/7/7 Luigi B <L.Balzano at gmail.com>

> Dear All,
>  I have a matrix with only two columns and many rows. For instance
> {xi,yi}.
> For those xi<x0, I would like to set yi=0.
> I can only think of a very inefficient loop...
>
> thanks
> -Luigi-
>
>


  • Prev by Date: Manipulate not working
  • Next by Date: Re: Looping- Programming
  • Previous by thread: Re: put some elements to zero
  • Next by thread: Re: put some elements to zero