Message Boards Message Boards

GROUPS:

ListPlot a list of numbers in string format?

Posted 10 days ago
119 Views
|
2 Replies
|
1 Total Likes
|

Hi,

What is the problem in using ListPlot command?

In[6]:= S1 = {"66.4", "2.8", "61.5", "504.4", "155.5", "155.5", "", 
  "", "", "", "", "", "", "", ""}

Out[6]= {"66.4", "2.8", "61.5", "504.4", "155.5", "155.5", "", "", \
"", "", "", "", "", "", ""}

In[7]:= S11 = DeleteCases[S1 /. "" -> x, x]

Out[7]= {"66.4", "2.8", "61.5", "504.4", "155.5", "155.5"}

In[8]:= ListPlot[S11]

enter image description here

2 Replies
Posted 10 days ago

Try this:

ListPlot[ToExpression@S11]
Posted 10 days ago

To add to the comment by Hans, the issue is that you're trying to use ListPlot on strings of real numbers, not real numbers themselves.

To get around this, Hans suggests using ToExpression to convert your strings of real numbers into proper numbers that ListPlot can work with.

In[10]:= ToExpression["12.2"]
Out[10]= 12.2
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract