Message Boards Message Boards

0
|
3681 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Unable to add decimals/adding text?

Posted 10 years ago

I have a code that is supposed to be able to determine the variation in some measurements. When I went to plot it it didn't plot. On further inspection it appears for some reason Mathematica is decinding not to add some decimals, leaving the result in the form "45.8654 (0.05 - 0.00012397 ) + 0.260788 " (note the spaces). If I copy and paste directly it leaves me with 45.8654 (0.05 - 0.00012397 TextCell[""])+0.260788 TextCell[""]. I can't figure out why it would be adding spaces into numerical results and I searched the code for spaces and incorrect variables and found none. I will admit that the code is a bit of a mess, but I've had codes that were more of a mess and didn't have this problem ever. Has anyone run into this type of thing before or by chance know to fix it?

Attachments:
POSTED BY: James Davis
5 Replies

Each Cell in a Mathematica notebook is, behind the scenes, a Cell[...] expression (and the notebook is a Notebook[...] expression), consistent with the usual Mathematica Mantra "Everything is an Expression". In a notebook, to see a Cell's Cell expression, select its cell bracket and use the Cell/ShowExpression menu item to see the expression. (Be sure to choose that menu item to show the formatted cell when you are done). Edit such Cell expressions carefully, it's quite easy to introduce syntax errors when doing this. But, this is a long winded way to say that this is how I found your problem and fixed it ;-)

I assumed that this was probably the sort of issue you were having from your detail of the symptoms.

POSTED BY: David Reiss

That is indeed what it was. I went through the old file and pulled out the Cell[""] bits and it produced the same results. Thank you for this bit of information.

POSTED BY: James Davis

For some reason, in part of your code an invisible embedded Cell[""] expression was placed internally and is now part of those expressions. This may have happened for a variety of reasons... however I am attaching a fixed version of your notebook where I removed them.

It seems to work fine now.... (I removed the unnecessary Quit[] statement at the beginning of the notebook but you can put it back if you wish).

Attachments:
POSTED BY: David Reiss

Thanks! How did you go about removing them? Scanning through the fixed version it appears to be the same as the broken version I initially had with the exception of some formatting changes.

POSTED BY: James Davis
In[45]:= 45.8654 (0.05 - 0.00012397) + 0.260788

Out[45]= 2.54837
POSTED BY: S M Blinder
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