Re: "Not a floating-point number" WHY?
- To: mathgroup at smc.vnet.net
- Subject: [mg70463] Re: "Not a floating-point number" WHY?
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 17 Oct 2006 02:58:26 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <egvbr1$s16$1@smc.vnet.net>
Henning Heiberg-Andersen wrote: > Hi, > > I have a hard time trying to understand why I get the floating-point error > in this > particular case: I dont't see what's wrong with the list I am trying to > plot. > Here it is: > > > In[1]:= small=Take[vec,2] > > Out[1]:= { {30.06, 23523}, {56. 38,00005}} > > In[2]:= ListPlot[small] > > Then I get the error message: > > Graphics::gptn : Coordinate 30.06 in {30.06, 23523} is not a floating-point > number. > > Hope someone can explain this to me. > > Best regards, > > Henning Heiberg-Andersen > > Hi, Looking at what you posted, I am confident that the values hold by vec are in string format. You can check that with Map[Head, small, {-1}]. Now you can transform the strings into expressions by using ToExpression, but beware that your data set seems odd: an entry such as 00005 is going to be converted as 5. However, 56. 38 will become 2128. since the white space is going to be interpreted as implicit multiplication. In[1]:= small={{"30.06","23523"},{"56. 38","00005"}} Out[1]= {{30.06,23523},{56. 38,00005}} In[2]:= ListPlot[small]; From In[2]:= Graphics::"gptn":"Coordinate 30.06 in {30.06, 23523} is not a floating-point number. In[3]:= Map[Head,small,{-1}] Out[3]= {{String,String},{String,String}} In[4]:= small=ToExpression[small] Out[4]= {{30.06,23523},{2128.,5}} In[5]:= Map[Head,small,{-1}] Out[5]= {{Real,Integer},{Real,Integer}} In[6]:= ListPlot[small]; Regards, Jean-Marc