MathGroup Archive 2006

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

Search the Archive

Re: How to extract numbers from list elements with text?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70378] Re: How to extract numbers from list elements with text?
  • From: dimmechan at yahoo.com
  • Date: Sat, 14 Oct 2006 03:08:30 -0400 (EDT)
  • References: <egn9a3$1em$1@smc.vnet.net>

Here is list of random data (I have converted everything to InputForm)

data = Table[{n, Random[]}, {n, 10}]
{{1, 0.12413290006809308}, {2, 0.7093848259927291},
{3,0.7231613965404428},{4, 0.6107033400153596},
{5, 0.6630864361893913}, {6,0.28357915808928474},
{7, 0.7675789962831012}, {8, 0.9745117436632931},
{9,0.9357614074319321},{10, 0.5083829540868412}}

Here is how you put in the format you want  {i Intensity j,...}

(StringJoin[ToString[#1[[1]]], " Intensity ", ToString[#1[[2]]]] & )
/@data
{"1 Intensity 0.124133", "2 Intensity 0.709385",
"3 Intensity 0.723161","4 Intensity 0.610703",
"5 Intensity 0.663086", "6 Intensity 0.283579",
"7 Intensity 0.767579", "8 Intensity 0.974512",
"9 Intensity 0.935761","10 Intensity 0.508383"}

And here is how you extract the second element of the list

(#1[[2]] & ) /@ data
{0.12413290006809308, 0.7093848259927291, 0.7231613965404428,
0.6107033400153596, 0.6630864361893913, 0.28357915808928474,
0.7675789962831012, 0.9745117436632931, 0.9357614074319321,
0.5083829540868412}

Regards
Dimitris


  • Prev by Date: Re: Beginner--[Plz Help] I don't want to display a POLARPLOT but use SHOW Command
  • Next by Date: Re: How to extract numbers from list elements with text?
  • Previous by thread: Re: How to extract numbers from list elements with text?
  • Next by thread: Re: How to extract numbers from list elements with text?