Hello,
I want to convert the Time in a timeseries object called GPSts (which currently is posixtime with nanoseconds e.g. "1604328037.75777") to datetime in the format 'HH:mm:ss.SSS' e.g. "23:46:11.4570".
I can convert the posixtime to the desired datetime using:
datetime(round(1000*GPSts.Time),'ConvertFrom','epochtime','Epoch', '1970-01-01', "TicksPerSecond",1000,'Format','HH:mm:ss.SSSS')
but when I try to modify the value of GPSts.Time I get the following errors:
Check for missing argument or incorrect argument data type in call to function 'isnan'.
if any(isinf(time)) || any(isnan(time))
t = timeseries.tsChkTime(t);
this.TimeInfo = reset(this.TimeInfo,input);
Please see my complete code example:
clcclearrosbagFolder = 'C:\Users\georg\OneDrive\Desktop\Rosbag';filePattern = fullfile(rosbagFolder, '*.bag');rosbagFiles = dir(filePattern);GPSts = timeseries();for i = 1 : length(rosbagFiles) bag = rosbag(rosbagFiles(i).name); bagSelGPS = select(bag, 'Time',... [bag.StartTime bag.EndTime], 'Topic', '/gx5/gps/fix'); MsgsGPSTimeseries = timeseries(bagSelGPS, 'Latitude', 'Longitude', 'Altitude'); GPSts = append(GPSts, MsgsGPSTimeseries); endGPSts.Time = datetime(round(1000*GPSts.Time),'ConvertFrom','epochtime','Epoch', '1970-01-01', ... "TicksPerSecond",1000,'Format','HH:mm:ss.SSSS') %Error occurs here
gpsFrameDuration = median(diff(GPSts.Time));gpsFrameDuration.Format = "s";gpsRate = 1/seconds(gpsFrameDuration);
Best Answer