error when using datetime()

17 ビュー (過去 30 日間)
MA
MA 2021 年 10 月 15 日
コメント済み: MA 2021 年 10 月 15 日
I am trying to read some data file and then use datetime() to represent the datetime objects, the file looks like this
the issue is the Day column is seperated whth ',' from the Sflux column in the data file which resulting in an error when using datetime(). how can I fix this?
the error I am getting
Error using datetime (line 547)
Invalid parameter name. Parameter name must be a nonempty string or character vector.
Error in cateogorizing (line 49)
S.date = datetime(S.Year, S.Month, S.Day,0,0,0,'Format', 'uuuuMMddHHmm');
Thanks in adavence,

採用された回答

Dave B
Dave B 2021 年 10 月 15 日
編集済み: Dave B 2021 年 10 月 15 日
Does it work if you add str2double? like this:
S.date = datetime(S.Year, S.Month, str2double(S.Day), 0, 0, 0, 'Format', 'uuuuMMddHHmm');
Or even better, just permenantly update that variable:
S.Day = str2double(S.Day);
  1 件のコメント
MA
MA 2021 年 10 月 15 日
Thank you.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by