converting from integer time to datetime in 3-hourly data
Mostrar comentarios más antiguos
I've tried everything I can think of to convert from integer time to datetime. Anyone have any intuitions or suggestions? Thanks!
time
Size: 13208x1
Dimensions: record
Datatype: double
Attributes:
standard_name = 'time'
long_name = 'Time'
units = 'hours since 1979-12-01 00'
time_calendar = 'gregorian'
start = '1979120100'
step = '3'
With having a time step of '3' I'm not sure how to apply the datetime function.
For reference:
>> time(1)
ans =
176064
6 comentarios
Carrie Merritt
el 1 de Dic. de 2020
My answer moved here:
X = {'1979120100', '1979120103', '1979120106'}
T = datetime(X,'InputFormat','yyyyMMddhh','Format','yyyy-MM-dd HH:mm')
result is:
T =
1×3 datetime array
1979-12-01 00:00 1979-12-01 03:00 1979-12-01 06:00
Some calculation:
>> T(3)-T(1)
ans =
duration
06:00:00
Stephan
el 1 de Dic. de 2020
Carries comment moved here:
Hi Stephan,
Thanks for the response. If you notice, I referenced the first time integer (e.g., time(1) = 176064). The method you have suggested assumes I already have a time vector in the 'yyyyMMddHH' format. Which I do not. It is what I need though.
I'm not sure what kind of time units I'm working with aside from what information I have in the netCDF file.
Stephan
el 1 de Dic. de 2020
I see, can you attach the data object you have there?
Carries comment moved here:
Please see attached. There isn't anything on the script aside from my numerous failed attempts at trying to make this work. All I'm trying to do is read the time in and convert it from its original netCDF format to a date/time format.
Walter Roberson
el 1 de Dic. de 2020
Is it possible that the first time should be 05-Jun-1982 ?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
