Converting timestamp from TDMS LabView
조회 수: 13 (최근 30일)
이전 댓글 표시
I received measurement data using LabView as a TDMS file and use TDMS reader from https://se.mathworks.com/matlabcentral/fileexchange/30023-tdms-reader to import it. The file name itself already indicated date and time of the measurement, e.g., COP_meas1_25-01-27_1237.tdms, but the resolution was only 1 s.
Using excel with AddOn from NI, I got the following results:

From values attached to this question.
Using
datetime(timestamp(1:5),'ConvertFrom','datenum','TicksPerSecond',1e4,'Format','HH:mm:ss.SSSS')
I got the following results.
05:37:04.1507
05:37:04.1520
05:37:04.1532
05:37:04.1545
05:37:04.1557
Using
datetime(timestamp(1),'ConvertFrom','posixtime')
I got
09-Jan-1970 13:27:24
I have tried using various combinations but I failed. How should I use the parameters to get the same results as in Excel?
댓글 수: 0
채택된 답변
Star Strider
2025년 1월 29일
편집: Star Strider
2025년 1월 29일
I did not see the .mat file before, although I did look for it.
Try this —
LD = load('timestamp.mat')
format long
timestamp = LD.timestamp
Time24 = datetime(timestamp, ConvertFrom='datenum', Format='MM/dd/yyyy HH:mm:ss.SSS', TimeZone='+02:00')
LastLine24 = Time24(end)
TimeAP = datetime(timestamp, ConvertFrom='datenum', Format='MM/dd/yyyy hh:mm:ss.SSS a', TimeZone='+02:00')
LastLineAP = TimeAP(end)
I prefer 24-hour time. I posted conversions for both here.
I am not certain what sort of resolution you want (or what the data provide). I have them in µs here. Append more ‘S’ characters to get additional displayed precision.
The Format name-value pair determines how the datetime values are displayed. It keeps full internal precision regardless.
EDIT — (29 Jan 2025 at 13:22)
Adeded timestamp.mat file import and changed the datetime calls to accommodate it.
EDIT — (29 Jan 2025 at 14:42)
Corrected (added) time zone offset, changed seconds resolution from 6 to 3 (µs to ms). .
.
댓글 수: 7
Star Strider
2025년 1월 30일
As always, my pleasure!
The solution was defining the TimeZone of the original as 'Z' (or equivalently, 'UTC'), although I thought that was the default. After that, defining the other time zones is straightforward.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Standard File Formats에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!