フィルターのクリア

Create a time vector from 01/01/1953 to 10/10/2010

1 回表示 (過去 30 日間)
Derol sakpak
Derol sakpak 2021 年 12 月 17 日
コメント済み: Eric Sofen 2022 年 4 月 12 日
Hello I am a beginner on matlab and I would like to create a time vector from 01/01/1953 to 10/10/2010. Then convert them to Julian day. Thank you
  2 件のコメント
Stephen23
Stephen23 2021 年 12 月 17 日
編集済み: Stephen23 2021 年 12 月 18 日
Here is a time vector that exactly fulfills your specification:
D = datetime([1953,2020],[1,10],[1,10])
D = 1×2 datetime array
01-Jan-1953 10-Oct-2020
It is a vector going from 01/01/1953 to 10/10/2010. Because you did not specify the step size, it has a completely randomly selected step of 594096 hours, which just coincidentally happens to be the exact difference between those dates.
TIP: do NOT use outdated and deprecated DATENUM nor DATEVEC. Using robust DATETIME objects is much better:
dt = datetime(1953,1,1):calyears(10):datetime(2010,10,10)
dt = 1×6 datetime array
01-Jan-1953 01-Jan-1963 01-Jan-1973 01-Jan-1983 01-Jan-1993 01-Jan-2003
jd = juliandate(dt)
jd = 1×6
1.0e+00 * 2434378.5 2438030.5 2441683.5 2445335.5 2448988.5 2452640.5
Eric Sofen
Eric Sofen 2022 年 4 月 12 日
@Stephen, thanks for steering folks away from datenum and toward datetime.
You can also use the convertTo datetime function to get Julian dates, among other time conversions. The juliandate function lives in the Aerospace toolbox.
dt = datetime(1953,1,1):calyears(10):datetime(2010,10,10);
jd = convertTo(dt,"juliandate")
jd = 1×6
1.0e+06 * 2.4344 2.4380 2.4417 2.4453 2.4490 2.4526

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by