MATLAB Answers

Replace 0 with nans in a table

81 ビュー (過去 30 日間)
Danielle Leblance
Danielle Leblance 2018 年 5 月 14 日
Answered: Peter Perkins 2018 年 5 月 14 日
I am attaching a table,
for the first row , I would like to replace zeros with nans for columns 8 to 13. This problems is repetitive in my codes where many times i have to replace 0 with nans where sometimes columns are a combination of categorical , string and number values. I am wondering if there is any code that would assign these nans across all column types without a problem

  0 件のコメント

サインイン to comment.

件の回答 (2)

Ameer Hamza
Ameer Hamza 2018 年 5 月 14 日
This will replace 0 from column 8 to 13 with nan,
Tb1{:,8:13}(Tb1{:,8:13}==0) = nan
nan belongs to double class, so you cannot add it to categorical or char columns. For those column you will have to choose an appropriate default value.

  0 件のコメント

サインイン to comment.


Peter Perkins
Peter Perkins 2018 年 5 月 14 日
The standardizemissing function should get you started.

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

タグ


Translated by