I got wrong data when i use datetime convertfrom

3 visualizzazioni (ultimi 30 giorni)
Hi I attached time(year:1999) data. It was nc data so when I use ncdisp, its units = 'hours since 1800-01-01 00:00:0.0'
I tried to convert it by
t=datetime(time,'Convertfrom',datenum);
And I got the answer like
'4780-11-26'
'4780-12-20'
.
.
.
Yeah it is wrong.
How can I get proper 1999 date?

Risposta accettata

Stephen23
Stephen23 il 15 Set 2022
S = load('time.mat');
D = S.time
D = 365×1
1744392 1744416 1744440 1744464 1744488 1744512 1744536 1744560 1744584 1744608
T = datetime(1800,1,1) + hours(D)
T = 365×1 datetime array
01-Jan-1999 02-Jan-1999 03-Jan-1999 04-Jan-1999 05-Jan-1999 06-Jan-1999 07-Jan-1999 08-Jan-1999 09-Jan-1999 10-Jan-1999 11-Jan-1999 12-Jan-1999 13-Jan-1999 14-Jan-1999 15-Jan-1999 16-Jan-1999 17-Jan-1999 18-Jan-1999 19-Jan-1999 20-Jan-1999 21-Jan-1999 22-Jan-1999 23-Jan-1999 24-Jan-1999 25-Jan-1999 26-Jan-1999 27-Jan-1999 28-Jan-1999 29-Jan-1999 30-Jan-1999

Più risposte (1)

Walter Roberson
Walter Roberson il 15 Set 2022
dt = hours(t) + datetime('1800-01-01 00:00:0.0')

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by