Converting time to usable format

After calling a data source (CSV or xlsx) I need to be able to utilize the time column which was currently depicted utilizing the following format: 319:17:19:21.28 (Day, Hrs, Min, Sec, mS). How can I convert this to a usable time stamp?

2 Comments

By time stamp, a time vector containing time values in specific units: 319:17:19:21.28 converted to 319*24*60*60 + 17*60*60 + 19*60 + 21 + 28/1000 seconds
It does not mater to me the format in which the time stamps are displayed in my results. I simply want to call the "load" function to load my data file and gather my data. The first column I have is my time data which happens to be in the 319:17:19:21.28 format. When MatLab brings this column in, it cuts off the :17:19:21.28 values due to the semicolons thus only saving the 319 as the time value for that column. I would like to have the entire time stamp, not just the first portion.
How can I do this?

Sign in to comment.

Answers (1)

Is this what you are looking for?
>> datetime('319:17:19:21.28','InputFormat','DDD:HH:mm:ss.SS','Format','dd-MMM-yyyy HH:mm:ss.SSS')
ans =
datetime
15-Nov-2018 17:19:21.280
There's no year in your timestamp, so datetime assume "this year". Or maybe you want an elapsed time, not a datetime. Beginning in R2018a, you can do this:
>> duration('319:17:19:21.28','Format','dd:hh:mm:ss.SS')
ans =
duration
319:17:19:21.28
The load function loads a mat file, so I'm not following how anything could be cut off. You're going to have to say more about how you are importing the data. For a CSV of XLS[X], best bet is likely readtable.

Categories

Asked:

on 5 Apr 2018

Answered:

on 6 Apr 2018

Community Treasure Hunt

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

Start Hunting!