フィルターのクリア

Replace NaN with next good value in a certain column of a table

17 ビュー (過去 30 日間)
BN
BN 2019 年 12 月 20 日
コメント済み: BN 2019 年 12 月 20 日
I have T2.mat which is a table with 12 columns. I want to replace NaN in columns 5:7 (5 to 7) by exactly the next good value in each column. I don't want to replace NaN in other columns.
I searched a lot and tried hard to do this. I was read the question in the link below:
but I want to do this in just columns 5 to 7 and not for rest of the columns. I attached T2.mat if it's help
Does anyone know how I can do this?
Thank you,
Behzad

採用された回答

Guillaume
Guillaume 2019 年 12 月 20 日
編集済み: Guillaume 2019 年 12 月 20 日
It's as simple as:
T2 = fillmissing(T2, 'next', 'DataVariables', {'lat', 'lon', 'station_elevation'})
or
T2 = fillmissing(T2, 'next', 'DataVariables', 5:7)
I recommend the first expression as it is clearer as to which variable is to be filled (and will work even if the order of the columns changes).
  1 件のコメント
BN
BN 2019 年 12 月 20 日
Works perfectly! Thank you so much. you really help me.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by