How to read time from a .txt file ?

I have got a column of time in the format "hh:mm:ss.SSS". How do i read this entire column in Matlab and convert it into decimal ?

1 Comment

Use readtable() to read the file.
The problem is Matlab is only reading hh:mm:ss . I have my data in milliseconds like this 00:00:01.456 . How do i potentially convert this to decimal system?
With the example you gave it worked fine for me. Perhaps show the code that you are trying to read the file and if possible upload the file.

Sign in to comment.

Answers (1)

So basically i am importing the data from the .txt file and reading the first column and fifth column. I am then using diff function to calculate dx/dt. The problem is with time. Since its not considering the milliseconds part i am getting 0 as the answer when i use diff function for time.

1 Comment

Prajwal, this may just be a display issue. Try this:
t.Time.Format = "hh:mm:ss.SSS"
(Substitute the correct names of your table and the time variable.) If that's not it, you should confirm that you are reading them in as durations (which has only been suppoted since R2018a IIRC).
Your code uses load. I'm not even sure what that would do on your file. Use readtable.

Sign in to comment.

Categories

Tags

Community Treasure Hunt

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

Start Hunting!