How to input a file and write timestamp of 2ms difference in to csv

1 view (last 30 days)
Hello,
I would like to input a file which has a time stamp and i would like overwrite or replace the column with a time stamp that has 2 ms difference. The start time would be 15:53:00 and 2 ms difference should be calculated from this particular start time.
Any help to solve this issue is appreciated. Thanks in advance.
Best Regards,
  5 Comments
Jan
Jan on 25 Mar 2019
It is much smarter to post text as text or as an attachment in the forum. I cannot use the data from the screenshot to suggest a solution, except if I spend the time to re-type the data. The screenshot does not reveal, how the data is stored in the file, but only, what you get after importing and converting it.
Again: Please post a small example of the input data in a usable form and if you show us, how the output should look like, the explanation would be clear. You have mentioned: "start time would be 15:53:00" and "start time 15:55:10:012 that is given in the file". This forces us to guess, what you want.
Revathi Balasubramanian
Revathi Balasubramanian on 25 Mar 2019
Hi Jan,
Thanks for the suggestion. I have attached the sample file. As stated in the data the start time is 15:55:10:012. But the data rows has some time units. I would like to discard the values and calculate the real timestamp with 2 ms difference from the start time 15:55:10:012 followed by 15:55:10:014 for next row and so on..

Sign in to comment.

Answers (1)

Peter Perkins
Peter Perkins on 25 Mar 2019
It's not clear to me what your question really is, or how far you have gotten. The answer to your specific question about creating a sequence of timestamps is to use datetime arithmetic:
>> d0 = datetime('19.11.2018 15:55:10.012','Format','dd.MM.yyyy HH:mm:ss.SSS')
d0 =
datetime
19.11.2018 15:55:10.012
>> d = d0 + milliseconds(0:2:5)'
d =
3×1 datetime array
19.11.2018 15:55:10.012
19.11.2018 15:55:10.014
19.11.2018 15:55:10.016

Community Treasure Hunt

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

Start Hunting!