How to remove the sec from the time when Timetable writing to .txt file?

55 vues (au cours des 30 derniers jours)
Tom Wills
Tom Wills le 22 Oct 2020
Commenté : Tom Wills le 22 Oct 2020
I am writing some code to write some captured data to a txt file. When I do this with the code below,
writetimetable(t,nameData);
The time colum has the time in seconds followed by "sec". Any methods for removing this.
  2 commentaires
Sudhakar Shinde
Sudhakar Shinde le 22 Oct 2020
The result you want to be only the numbers in 'Time' column without word 'sec'?
Tom Wills
Tom Wills le 22 Oct 2020
Yes that is the aim

Connectez-vous pour commenter.

Réponse acceptée

Adam Danz
Adam Danz le 22 Oct 2020
Modifié(e) : Adam Danz le 22 Oct 2020
  1. Convert timetable to table using T = timetable2table(TT)
  2. Convert the duration column using S = seconds(X)
  3. Write that table using writetable(T)
Demo:
s = seconds(1:10)
s = 1×10 duration array
1 sec 2 sec 3 sec 4 sec 5 sec 6 sec 7 sec 8 sec 9 sec 10 sec
sd = seconds(s)
sd = 1×10
1 2 3 4 5 6 7 8 9 10
Since you're working with a timetable, you'll need to convert it to a table,
tt = timetable(seconds(1:5)', (11:15)')
tt = 5x1 timetable
Time Var1 _____ ____ 1 sec 11 2 sec 12 3 sec 13 4 sec 14 5 sec 15
t = timetable2table(tt)
t = 5x2 table
Time Var1 _____ ____ 1 sec 11 2 sec 12 3 sec 13 4 sec 14 5 sec 15
t.Time = seconds(t.Time)
t = 5x2 table
Time Var1 ____ ____ 1 11 2 12 3 13 4 14 5 15
Now you can write write the data using writetable(T)

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by