Strange postfix quotes in mathematica output

Click For Summary

Discussion Overview

The discussion revolves around an issue encountered while using the Smooth.m Mathematica package on a dataset, where unexpected string outputs appear in the numerical results, preventing proper evaluation of the data. Participants explore the nature of the output and potential causes, focusing on data manipulation and import processes.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant reports encountering unexpected string outputs in their numerical array, which seem to prevent evaluation.
  • Another suggests using FullForm to inspect the output array for details that might clarify the issue.
  • A participant shares a snippet of their output, indicating that the problematic entries involve a Times and Plus operation with a null string.
  • One participant proposes inserting checks in the calculations to identify variables that might be causing the null string issue.
  • Another participant expresses confusion about implementing the suggested checks and shares their code for context.
  • One participant suggests examining the FullForm of the data vectors to identify potential null strings hidden in the data.
  • A participant identifies that the issue arose from importing data from an Excel spreadsheet, which introduced null characters due to extra blank sheets.

Areas of Agreement / Disagreement

Participants generally agree that the presence of null strings is causing the issue, but the exact source and method of resolution remain under discussion. There is no consensus on a definitive solution yet.

Contextual Notes

The discussion highlights limitations related to data import processes and the handling of dimensionality in Mathematica, which may contribute to unexpected outputs. Specific assumptions about data structure and function behavior are not fully resolved.

wil3
Messages
177
Reaction score
1
Hello. I am using the Smooth.m mathematica package on a large set of paired data points. Occasionally, instead of getting a number in my output array, I end up with something like this:

1. (0.861515 + (58 "")/2379)

In the output window, the quotes are not visible, but when I copypasta it as input, I can see them. I've played around, and they seem to prevent the expression from being evaluated (perhaps by converting the numerator to a String?). I've tried using ToExpression[], but that doesn't seem to work out.

This is important because the random five or so points I get like this prevent me from using the smoothed output list as an array of Reals.

Thanks for any advice. I'm on OSX with Mathematica 8
 
Physics news on Phys.org
Suppose your output array is stored in X.

Do

FullForm[X]

and carefully inspect the result from that. This should show enough details to determine what is wrong with the result. Perhaps from that we can backtrack to what caused the problem.

If you can narrow the problem down to say the 14't entry in X then you can post the output from

FullForm[X[[14]]]

and that will help others diagnose what the problem is if you can't find it yourself.
 
Okay, I get where you're going with this. Here's a snippet of the output (the rest of the data set is more of the same, with the irrelevant parts of the set elided:

List[List[1.26882, 0.37328, -0.106096, -0.92101, -0.136833],
List[-3.22256, -0.813948, -0.711458, -0.68961, -1.00191],

...

List[0.655709, 0.0882863, 0.842526, 0.341742, 0.549153], \
List[-0.647317, 0.590783, 0.930406, 0.641969, -1.22252], \
List[-0.669536, -0.712783, -1.47811, 0.109366, -0.496347], \
List[0.943894, -0.733368, -0.541758, 0.128392, 1.09628], \
List[0.24907, 0.403836, 1.12949, -0.757977, -0.566415],
List[-2.01784, 0.822378, 0.608782, 0.0639815, 0.388811], \
List[0.941022, -0.233806, -1.21123, 0.777403, 0.191461], List[
Times[1.,
Plus[1.26945,
Times[Rational[58, 2379],
""]]], -0.685587, -0.671428, -0.470756, -0.668355], List[
Times[1.,
Plus[0.754083,
Times[Rational[88, 2379],
""]]], 0.354215, 1.63487, 0.279868, -0.183664], List[-0.439363, \
0.267128, 0.597456, 0.429185, 0.234532], List[1.52809, -0.232724, \
-0.697609, -0.972193, 0.809927],

...

List[-0.18374, 0.660093, 1.04566, -0.166718, 0.0239493],
List[1.59315, 0.445269, 1.01502, 0.31377, 0.56214]]So the TimesRational thing is definitely it, but I don't think I understand yet what is going on. Thanks for your help!
 
Good. So it really does appear that you have a zero character string getting into one of your calculations.

Can you now back up into the calculation of this matrix and insert some

If[y=="",Print["Yikes! y is a null string"]];

and do that for each of the variables that are going to be used next in a calculation.

Hopefully that will help you track down which variable is responsible.
 
I'm confused as to how to implement that. The code I'm using is:

x =
Table[
Smooth[
Partition[
Riffle[wavelength, hiradmiki1[]], 2],
60, 5],
{i, Length[hiradmiki1]}];

where 60 and 5 are parameters of the Smoothing function. hiradmiki1 is my original absorbance data set, and wavelength is the set of ordinates for each point in the data set (Smooth[] won't let me call a 1D data set alone; I have to give it paired values).

The Partition of the Riffled set looks fine in testing, but once I add the Smooth layer it causes the issue. If I comment out Smooth[], then it generates the unsmoothed table without any issues. Is there a simple command to find and remove all the zero character Strings?
 
Ah, so you are doing a whole vector against vector.

Try this instead.

Do a FullForm on your savelink and then on your kiradmiki1 and see if there is any chance that a null string might be hiding inside either of those.

You might be able to narrow your search by counting which elements have the "" in them, or you can just manually scan the output, or possibly search for "".
 
Okay, I got it. So I was importing my data vectors in matrix form from an Excel spreadsheet. The import feature seems to add a layer of dimensionality to the list(I guess with sheet number as the third tensor dimension?), which was getting recorded as a group of null characters because my extra sheets were blank.

I had been transposing, and then flattening the data set(to kick the third dimension), but I needed to do the operations in reverse in order to prevent zero character artifacts of the import process (from the third "sheet number" dimension) from getting scattered throughout my transposed vector.

Thanks very much for your help. I think you've answered some of my other Mathematica questions correctly as well. Pro
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 52 ·
2
Replies
52
Views
13K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 17 ·
Replies
17
Views
46K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K