MATLAB Answers

how to get the value in julian date and time

6 ビュー (過去 30 日間)
MONICA RAWAT
MONICA RAWAT 2020 年 5 月 7 日
コメント済み: MONICA RAWAT 2020 年 5 月 8 日
suppose we have 2014-04-29 4:35:22 date and time then how to convert the date and time together in julian, keeping 2000 as a starting reference.

  2 件のコメント

Michael Soskind
Michael Soskind 2020 年 5 月 7 日
Is there a reason that the function juliandate does not work for you? Are you using Matlab 2014b or newer?
MONICA RAWAT
MONICA RAWAT 2020 年 5 月 7 日
i am using matlab 2019a

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

採用された回答

Kelly Kearney
Kelly Kearney 2020 年 5 月 7 日
Can you explain what you're defining as "Julian date"? While the 4714 BCE reference date is the proper one for a real Julian date, I know the term is often used in my field to mean either day-of-year or days-since-reference-date. My guess is you want the last option, in which case
tstr = '2014-04-29 4:35:22';
jd = days(datetime(tstr) - datetime(2000,1,1))

  1 件のコメント

MONICA RAWAT
MONICA RAWAT 2020 年 5 月 8 日
thank you so much kelly

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

その他の回答 (1 件)

Michael Soskind
Michael Soskind 2020 年 5 月 7 日
Hi Monica,
The following code should work for your example:
% Julian Date Example
% modified from https://www.mathworks.com/help/matlab/ref/datetime.juliandate.html
t1 = datetime('2014-04-29 4:35:22'); % Time input in traditional datetime format
t1.TimeZone = 'America/New_York' % Setting the timezone
% Printing the Julian date as the number of days and fractional days since
% noon on November 24, 4714 BCE
format longG % Defining the format to print Julian Date
jd1 = juliandate(t1)
Hope that helps,
Michael

  2 件のコメント

MONICA RAWAT
MONICA RAWAT 2020 年 5 月 7 日
yeah i tried this,but the reference point is from November 24, 4714 BCE, but i want from 2000
Michael Soskind
Michael Soskind 2020 年 5 月 7 日
Sorry I misinterpretted the question; Kelly just answered that for you, below.

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

Community Treasure Hunt

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

Start Hunting!

Translated by