Linear Interpolation on missing data
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a time series and i tried using linear interpolation on that data. But linear interpolation seems to change the original data too (not significantly). Is there a way I can keep the values for original data same. I think i need to use a loop but not sure how to use it in linear interpolation.
1 comentario
John D'Errico
el 26 de Sept. de 2015
Please don't add a new answer every time you wish to make a comment. Use the comments. That is why links are provided for comments. USE THEM.
Respuestas (1)
Star Strider
el 26 de Sept. de 2015
We need to see your code. The interp1 function has not (at least in my experience) changed any of the original data. Don’t use a loop if you can use interp1 or another appropriate interpolation function.
4 comentarios
Star Strider
el 26 de Sept. de 2015
That code looks as though it should work. If you end up extrapolating beyond your actual data (that will produce NaN output from interp1), you have to change your interp1 call to:
dornq = interp1(Qdorn(:,1),Qdorn(:,2),interpQ, 'linear', 'extrap');
This will work even if you don’t extrapolate.
Image Analyst
el 26 de Sept. de 2015
How did you determine the x values stored in interpQ? If you find that the y values, dornq, at the same x value are different, then either your interpQ values don't match up with the Qdorn(:,1) values, or you're not looking at the right index.
The first case would be like your original x values are 1,2,3,5 and you're specifying interpolated x locations of 1.5, 2.5, 3.5, 4.5, and 5.5. Of course the y value at 1 is not going to be the same as the y value at 1.5
In the second case, if your original x values are 1,2,3,5, and your interpolated x values are 1,2,3,4,5, then your original y(4) will not match your new interpolated y(4) because the original y(4) was the value for x=5 while the new y(4) is the value for x=4.
Make sense? Perhaps is that what is happening?
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!