Clear Filters
Clear Filters

How to interpolate missing value using n values before and after the missing data?

4 views (last 30 days)
Hello All,
I am trying to linearly interpolate a missing value by using values that were measured before and after the missing data. However, I don't want to use the first value measured before and after the missing data. Rather I would like use n values before and after the missing data for linear interpolation. How can I do that?
Here is an example of my problem:
I want to interpolate for value between x(5) and x(7). But I want to use n = 3 values before and after x(6) for linear interpolation. I.e. I want to use x(3), x(4), x(5) and x(7), x(8), x(9) values for interpolation.
x = [1 2 3 4 5 7 8 9 10];
Thanks,
Prashanti
  8 Comments
John D'Errico
John D'Errico on 12 Jan 2022
Edited: John D'Errico on 12 Jan 2022
@Jan Kudlacek - you CANNOT accept a comment as an answer. You never posted an answer, just a comment. If you think your comment deserves an acceptance, then you need to post it as an answer. We cannot even upvote comments.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!