Convert UNIX NanoSeconds to DTG in Milliseconds
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have to do 2 things: convert UNIX nanoseconds to DTG Nanoseconds, and then convert DTG Nanoseconds to DTG Milliseconds. The second conversion would be a "SUM" of all the entries into one millisecond. So for every nanosecond entry within millisecond "1," I would like to sum the different parts of the table and add them together to create a millisecond register instead of a nanosecond register. Does this make sense? Any questions are welcomed in order to reach this goal!
Thanks,
Tim
8 commentaires
Walter Roberson
le 19 Août 2023
If you had the time in int64 or uint64 nanoseconds, then to round to milliseconds, just divide them by 1000: operations on integer data classes automatically round
If you have double precision numbers, then see round which has the ability to indicate how many digits you want to round to.
Réponses (1)
dpb
le 19 Août 2023
Ah! That simplifies the problem immensely; you've already passed the hard part.
To do the initial request to sum over millisec time intervals, turn the data table into a timetable and use retime with the 'regular' sample rate and @sum method...
tt=timetable(yourdatetimevar,restofdata);
ttMS=retime(tt,'regular','sum','SampleRate',1000); % aggregate a msec sample rate
The above will start at the actual time in msec and aggreate within those groups; it will not resample to approximate at even msec times. If want that, use retime() and interpolate first, then aggregate. There may be a way to do both in one step, I'm not sure.
0 commentaires
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!