Convert UNIX NanoSeconds to DTG in Milliseconds
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2023-8-19
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.
回答(1 个)
dpb
2023-8-19
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!