Adding number of seconds from changing base date
Mostrar comentarios más antiguos
This ones been giving me some trouble. I'm calling a file where the 'time' variable is the seconds since midnight of the day of interest which constantly changes:
In this test example, I am attempting to call four days of data at one time in a for loop. 's' is just the changing file name, but here when I attempt to take the 'time_raw' from the time variable for each file, it gives me the seconds since midnight of the current day, not the days of interest. I attempted to make some datetime values (t) of the days of interest and thought to concatenate them together (day of interest plus datetime of seconds since midnight) but I am unable to at this time. Feel like I'm missing one line of code to fix this, just not sure what that would be.

Currently, my 't2' variable is the correct number of seconds found in 'time' but for August 12, 2020 not April 16-19, 2010.
Respuesta aceptada
Más respuestas (1)
Mohammad Sami
el 13 de Ag. de 2020
Since the time is given to you as seconds since some date. you can read it as a double and then add it to the date of interests.
dateofinterest = datetime(2010,04,16);
% read the seconds
s = 1:100; % replace with your code to read the value.
out = dateofinterest + seconds(s);
1 comentario
Eric Beamesderfer
el 13 de Ag. de 2020
Categorías
Más información sobre Programming 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!




