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

MathGroup Archive 2008

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

Search the Archive

Re: Replace non-numeric values in a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88747] Re: Replace non-numeric values in a list
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Fri, 16 May 2008 05:26:56 -0400 (EDT)
  • Organization: University of Bergen
  • References: <g0h825$mtr$1@smc.vnet.net>

Adel Elsabbagh wrote:
> Dear all,
> 
> I have a list that contains numeric and non-numeric values
> list = { a, 1, 2, b, 3};
> How can I replace non-numeric values with zeros?
> Thanks!
> 

This is one possibility:

Replace[{a, 1, 2, b, 4}, x_ /; ! NumericQ[x] -> 0, 1]


  • Prev by Date: Re: export mathematica table to .mat (MATLAB) format.Please help!!!
  • Next by Date: Re: Replace non-numeric values in a list
  • Previous by thread: Re: Replace non-numeric values in a list
  • Next by thread: Re: Replace non-numeric values in a list