How can I replace NaN elements with the nearest value in the same column?
古いコメントを表示
I am trying to replace NaN's in a vector field with the nearest value.
% I have:
M=
NaN 12
18 14
NaN NaN
NaN NaN
NaN 16
12 NaN
12 NaN
NaN 12
16 NaN
%I desire:
M=
18 12
18 14
12 16
12 16
12 16
12 12
12 12
16 12
16 12
Any information will be helpful. Thank you
2 件のコメント
AstroGuy1984
2017 年 4 月 25 日
編集済み: AstroGuy1984
2017 年 4 月 25 日
What do you mean by "nearest"? Do you mean "next good value"? Because that's what you appear to desire. For example the second NaN in column 1 is closer to 18 than 12.
sal135
2017 年 4 月 26 日
採用された回答
その他の回答 (1 件)
dpb
2017 年 4 月 25 日
0 投票
カテゴリ
ヘルプ センター および File Exchange で NaNs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!