Interpolate include NaN data.
1 次查看(过去 30 天)
显示 更早的评论
Data likes this
-----
3
NaN
NaN
7
NaN
NaN
2
NaN
NaN
19
NaN
NaN
12
-----
How interpolate NaN data?
I try interp1 fuction. But I failed.
Please help me.
1 个评论
采纳的回答
John D'Errico
2016-11-14
编辑:John D'Errico
2016-11-14
Download inpaint_nans from the File Exchange. Although interp1 would also have been able to solve the problem too. inpaint_nans is far simpler to use for this though.
4 个评论
John D'Errico
2016-11-14
This is easier?
k = find(~isnan(x));
y = interp1(x(k),y(k),1:numel(x));
It is not difficult. But you cannot claim it to be simpler to use interp1 here.
更多回答(1 个)
Jan
2016-11-14
data = [3, NaN, NaN, 7, NaN, NaN, 2, NaN, NaN, 19, NaN, NaN, 12];
miss = isnan(data);
data(miss) = interp1(data(~miss), find(~miss), find(miss))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation of 2-D Selections in 3-D Grids 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!