フィルターのクリア

How do I replace (or remove) <undefined> with NaN in a categorical array ?

40 ビュー (過去 30 日間)
Douglas Leaffer
Douglas Leaffer 2022 年 12 月 8 日
コメント済み: Douglas Leaffer 2022 年 12 月 9 日
How do I replace (or remove) <undefined> with NaN in a categorical array ? .dat file excerpt is attached. Thanks for any help !

採用された回答

Cris LaPierre
Cris LaPierre 2022 年 12 月 8 日
<undefined> is the value used for a missing categorical entry. NaN is for missing numerical values.
You can replace missing values using fillmissing
  3 件のコメント
Cris LaPierre
Cris LaPierre 2022 年 12 月 8 日
編集済み: Cris LaPierre 2022 年 12 月 8 日
Your table variable source is of type categorical, so you must use a valid categorical data type, which is categorial, char array, or string.
  • categorical(0)
  • "0"
  • "None"
Here is an example that uses "None"
load Table4excerpt.mat
T41.source = fillmissing(T41.source,'constant',"None")
T41 = 40×10 table
Datetime Temp Hum DP WS Deg Bar Rain UFPConc source ____________________ _____ ____ _____ ___ ______ ______ ____ _______ ______ 17-Aug-2016 05:34:44 81.51 78.1 74.05 4.2 245.25 29.848 0 12460 None 17-Aug-2016 05:34:45 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:46 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:47 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:48 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:49 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:50 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:51 81.5 78 74 4 247.5 29.848 0 49020 train 17-Aug-2016 05:34:52 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:53 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:54 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:55 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:56 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:57 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:58 81.5 78 74 4 247.5 29.848 0 49020 None 17-Aug-2016 05:34:59 81.5 78 74 4 247.5 29.848 0 49020 None
Douglas Leaffer
Douglas Leaffer 2022 年 12 月 9 日
Thank you. My script is fine now

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by