Converting time to a epoch
2 views (last 30 days)
When I have time data of a colum (Excel file) and each column has a data like "15:20:20" which means 3 something p.m.
So, there is only time information but not data. Suppose that the column is 100-by-1.
How can I convert it to time epoch such as a single number.
Cris LaPierre on 24 Sep 2021
Edited: Cris LaPierre on 25 Sep 2021
In MATLAB, you can read this in as a duration (see options here) using readtable. It may autodetect the time correctly. If not, you can manually specify it using code similar to this:
opts = detectImportOptions("filename.xlsx");
opts = setvartype(opts,1,'duration');
opts = setvaropts(opts,1,'InputFormat','hh:mm:ss');
data = readtable("filename.xlsx",opts)
Once imported, you can modify the format as you like. You can also use the following functions to represent the duration in a single unit of time like days, hours, minutes, and seconds