limit fillmissing() to only perform fill if the data gap is a single point
9 views (last 30 days)
Show older comments
I am climate reading data into a timetable, some of the data has gaps of varying size. I am trying to control how data is backfilled when it is missing. Right now I am ussing something like this
dataTable.AirTemp = fillmissing(dataTable.AirTemp, 'linear');
Which seems to work fine for what I need. (see picture attached). However I am trying to find a simple way to make it only fill gaps that are a one or two NaN long. If there are multiple NaN in a row, I don't want to fill the gap. I don't see any input options that wold control that. Is there a better method or an elegant solution for this? I've got to imagine this is common.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/295778/image.png)
0 Comments
Answers (1)
Shubh Sohal
on 6 Oct 2020
Hi Justin, I believe using 'MaxGap' parameter with the fillmissing function would be helpful to achieve what you want in your case.
This will allow you to fill the missing values only depending on the MaxGap that you will define using the sample point unit input. So, in case you want to only fill a single NaN occurrence or two consecutive NaN occurrences, you can specify the 'MaxGap' value accordingly.
0 Comments
See Also
Categories
Find more on Glaciology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!