0

I have the following:

x = 1:365;
y = T;
xx = missing;
yy = spline(x,y,xx)

I have data T, which is 365 days of data, and missing is a vector containing the days on which the data is faulty. I need to generate estimated values at the missing days. However, when I use the above syntax, it returns a vector of 0s. What am I doing wrong?

Nylo
  • 3
  • 1
  • 1
    What values are you using for `missing`? Can you include the data for `T` in your question? – eigenchris Mar 25 '15 at 18:20
  • I think it is a bit rash to say that the villain is `spline`. I tried on some test data andI think it is a bit rash to say that the villain is `spline`. I tried on some test data and `spline` seems to work fine. However, your implementation seems strange. That is of course impossible to say for sure unless I know what `T` or `missing` is. However the syntax is `newY = spline(oldX, oldY, newX)`. – patrik Mar 26 '15 at 13:54
  • What values does `y` aka `T` contain on those days where data is missing? Might it be a 0? – A. Donda Mar 26 '15 at 14:50

1 Answers1

0

I suspect the missing data are specified in your vector T as zeros. You give that information to spline to interpolate, and that's easy, the exact value is already there, it's a zero, and that is what is returned. Assuming that missing contains the day numbers where data is missing, try this:

x = 1:365;
y = T;
x(missing) = [];
y(missing) = [];
xx = missing;
yy = spline(x,y,xx)

This way the missing data are not encoded as zeros anymore, but they are actually missing, and spline can use the neighbors to estimate values.

A. Donda
  • 8,381
  • 2
  • 20
  • 49