How to read time from a .txt file ?

12 vues (au cours des 30 derniers jours)
Prajwal Kadlaplamutt Ravindra Kumar
Commenté : Peter Perkins le 11 Mar 2019
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 commentaire
madhan ravi
madhan ravi le 5 Mar 2019
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.

Connectez-vous pour commenter.

Réponses (1)

Prajwal Kadlaplamutt Ravindra Kumar
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 commentaire
Peter Perkins
Peter Perkins le 11 Mar 2019
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by