MathGroup Archive 2006

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

Search the Archive

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


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
> 
> 
As written, Mathematica is going to undergo some simplifications and 
assume that a space is an implicit multiplication.

In[1]:=
{1 Intensity 0.23523,2 Intensity 0.00005,3 Intensity 0.00004}

Out[1]=
{0.23523 Intensity,0.0001 Intensity,0.00012 Intensity}

To avoid this, your data must be imported/transformed as a list of list. 
Then, extracting the third column is straightforward.

In[1]:=
data=ReleaseHold[HoldForm[{1 Intensity 0.23523,2 Intensity 0.00005,3
Intensity 0.00004}] /. Times -> List]

Out[1]=
{{1,Intensity,0.23523},{2,Intensity,0.00005},{3,Intensity,0.00004}}

In[2]:=
data[[All,3]]

Out[2]=
{0.23523,0.00005,0.00004}

Regards,
Jean-Marc


  • Prev by Date: Re: How do you open all cells?
  • 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?