Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a bit of data that looks like this:

data = {79., 79.1, 78.3, 78.6, 79., 77.2, 79.3, 79.3, "", "", 79.3, 76.6, \
79.3, 79.8, 78.4, 79., 78.4, 78.4, 79.4, 79.5, 79.4, 79.3, 79.2, \
79.2, 79.3, 79.6, "", 79.2, 79.3, 79., 79.1, 79.2}

I'm looking to do Linear Interpolation to fill in the missing data. The Interpolation functions with InterpolationOrder->1 seems to be just what I am looking for. But I can't figure out how to feed the data to the Interpolation function in order to get a a sensible result.

share|improve this question

1 Answer 1

up vote 14 down vote accepted

You have to provide the values of independent variable. Assuming that the points correspond to equidistant values of an independent variable, you can do this, for example:

int = 
   Select[Transpose[{Range[Length[data]], data}], NumericQ[Last[#]] &],
   InterpolationOrder -> 1

Of course, you may wish to scale the independent variable here in some way.

share|improve this answer
Works perfectly, thank you! Looking at the solution it bugs me that I was soo close but couldn't quite put two and two together to get it right. –  Mr Alpha May 1 '12 at 13:51
@MrAlpha Glad I could help! Thanks for the accept. –  Leonid Shifrin May 1 '12 at 14:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.