Converting time to a epoch

조회 수: 12 (최근 30일)
John Lee
John Lee 2021년 9월 24일
편집: Cris LaPierre 2021년 9월 25일
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.

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 9월 24일
편집: Cris LaPierre 2021년 9월 25일
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
  댓글 수: 1
John Lee
John Lee 2021년 9월 25일
Thanks you for your help.
I found that one can convert the time to a single number by applying a function in the Excel file.
You can refer to the site on how to do it: https://www.youtube.com/watch?v=VKIOaWO0IrI
Thanks,

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by