Filling in missing points
5 次查看(过去 30 天)
显示 更早的评论
Hi, all. I have a quesion about filling missing points.
I need to fill in the missing points according to these rules:
- If there’s only one missing point, with valid data present on both sides of that point, the missing point shall be assigned the average of the two known data-points either side of it.
- If there are multiple, consecutive data-points missing, the closest known data point will be assigned to those missing values.
I have finished the first rule, but I don't know how to deal with second rule.
0 个评论
回答(1 个)
Andrei Bobrov
2020-3-30
编辑:Andrei Bobrov
2020-3-30
In R2016b:
T = readtable('weather_laverton.xlsx','Sheet',1);
TT = table2timetable(T);
TTout = fillmissing(TT,'linear');
Add
T = readtable('weather_laverton.xlsx','Sheet',1);
TT = table2timetable(T);
A = varfun(@f1,TT);
function out = f1(x)
b1 = fillmissing(x,'linear');
b2 = fillmissing(x,'nearest');
d = [0;diff(bwdist(~isnan(x)),2);0]==-2;
out = b2;
out(d) = b1(d);
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Other Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!