Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Strange postfix quotes in mathematica output

  1. Jul 3, 2011 #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
     
  2. jcsd
  3. Jul 3, 2011 #2
    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.
     
  4. Jul 3, 2011 #3
    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!
     
  5. Jul 3, 2011 #4
    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.
     
  6. Jul 3, 2011 #5
    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?
     
  7. Jul 3, 2011 #6
    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 "".
     
  8. Jul 5, 2011 #7
    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
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Strange postfix quotes in mathematica output
Loading...