Re: How to extract numbers from list elements with text?
- To: mathgroup at smc.vnet.net
- Subject: [mg70434] Re: How to extract numbers from list elements with text?
- From: dimmechan at yahoo.com
- Date: Mon, 16 Oct 2006 02:35:08 -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
Henning Heiberg-Andersen wrote:
> Hi,
>
> I have a list looking like this:
>
> { 1 Intensity 0.23523, 2 Intensity 0.00005, 3 Intensity 0.00004, ..}
>
> Is there a command which allows extraction of only the last number appearing
> in each element
> of the list?. If not, how can I modify the list elements?
>
> Best regards,
>
> Henning Heiberg-Andersen