MATLAB Answers

How could i convert timestamp to nanosecond and what would be the way to get data in nanoseconds for given period?

13 views (last 30 days)
Hello, Maybe someone could bring me on the right track. How could I convert the given time stamp to nanoseconds?
And what would be the way to get timestamps in nanosecond between period from 20180429 14:00:00.000000000 till 2018042914:00:00.000000000. It is needed that I could make comparisons between time and the given data like in example.


Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 8 Nov 2018
Call readtable. Reassemble the date and time string into one block of text then call datetime to convert that text representation into a datetime array.
t = readtable('answer428720.csv')
t.str = t.Var1 + " " + string(t.Var2)
fmt = 'yyyyMMdd HH:mm:ss.SSSSSSSSS';
t.timestamp = datetime(t.str, 'InputFormat', fmt, 'Format', fmt)
You could modify the readtable call or the import options to do this in fewer lines of code, but this is fairly readable IMO.


Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by