How to build a time record from several matrices?
1 view (last 30 days)
Show older comments
Hi, I have four matrices A, B, C, D and they are each (1x409752). These matrices are actually extracted from a time record that had format "Y-M-D H:MI:S:MS". A is now equal to H B is equal to MI C is equal to S D is equal to Ms
The start time from "Y-M-D H:MI:S:MS" is 13:58:52.12000 and the end time is 14:01:02.932000. Or from separate matrices: A(1) = 13; B(1) = 58; C(1) = 52; D(1) = 12000;
A(end) = 14; B(end) = 01; C(end) = 02; D(end) = 932000;
How can I combine matrix A, B, C and D to build a time stamp in seconds? I need this time stamp for plotting recorded data.
Many thanks!
0 Comments
Answers (2)
KSSV
on 11 Apr 2017
You can read the data from each file and combine them:
t = [A ; B ; C; D] ;
0 Comments
Peter Perkins
on 12 Apr 2017
If you're using R2014b or newer, use durations:
>> A = [1;2;3;4]; B = [5;6;7;8]; C = [9;10;11;12]; D = [13;14;15;16];
>> dt = duration(A,B,C,D);
>> dt.Format = 'hh:mm:ss.SSS'
dt =
4×1 duration array
01:05:09.013
02:06:10.014
03:07:11.015
04:08:12.016
>> plot(dt,x)
If you are creating A,B,C,D from text, you should skip the middle man and create a datetime from the text, then call timeofday to get the durations.
0 Comments
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!