Strange postfix quotes in mathematica output

In summary, it appears that the null character string is being inserted into one of the calculations in the Smooth.m package. This problem can be resolved by carefully inspecting the result from that calculation, and by inserting some ToExpression() calls to try and determine which variable is causing the problem.
  • #1
wil3
179
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
  • #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.
 
  • #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!
 
  • #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.
 
  • #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?
 
  • #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 "".
 
  • #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
 

What are strange postfix quotes in Mathematica output?

Strange postfix quotes in Mathematica output refer to the single or double quotes that appear at the end of some expressions or outputs in the Mathematica software. These quotes are not standard punctuation marks and are often confusing to users.

Why do strange postfix quotes appear in Mathematica output?

Strange postfix quotes appear in Mathematica output when the expression contains a symbol or string object that is not properly closed with a matching quote. This can happen when using certain functions or when manually entering expressions.

Do strange postfix quotes affect the accuracy of Mathematica computations?

No, strange postfix quotes do not affect the accuracy of Mathematica computations. They are simply a cosmetic issue and do not impact the functionality or results of the software.

How can I get rid of strange postfix quotes in Mathematica output?

To get rid of strange postfix quotes in Mathematica output, you can use the InputForm function to convert the expression to a standard input form. You can also manually remove the quotes by editing the expression.

Is there a way to prevent strange postfix quotes from appearing in Mathematica output?

Yes, you can prevent strange postfix quotes from appearing in Mathematica output by using the ToString function to convert the expression to a string before displaying it. This will ensure that the output does not contain any unexpected quotes.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
52
Views
11K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
  • Linear and Abstract Algebra
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
17
Views
45K
Back
Top