フィルターのクリア

convert int32 dates to matlab date (datenum)

2 ビュー (過去 30 日間)
Sri Adiyanti
Sri Adiyanti 2023 年 4 月 3 日
コメント済み: Peter Perkins 2023 年 4 月 5 日
Hi,
I work on netcdf4 file of a 2D model output. Date datatype is int32, how can I convert this into matlab date (datenume) or datetime?
Thanks.

回答 (1 件)

Stephen23
Stephen23 2023 年 4 月 3 日
編集済み: Stephen23 2023 年 4 月 3 日
"Date datatype is int32"
You did not tell us the most important information, which is the epoch and step size.
Assuming that those dates are UNIX format (ie. epoch 1st Jan 1970, 1 second steps) then use DATETIME like this:
U = uint32(1680508182)
U = uint32 1680508182
D = datetime(U,'convertfrom','posix')
D = datetime
03-Apr-2023 07:49:42
  1 件のコメント
Peter Perkins
Peter Perkins 2023 年 4 月 5 日
Stephen kind of buried the lede, which was "use DATETIME", not datenum.

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

カテゴリ

Help Center および File ExchangeTime Series Objects についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by