How to build a time record from several matrices?

1 回表示 (過去 30 日間)
EB
EB 2017 年 4 月 11 日
回答済み: Peter Perkins 2017 年 4 月 12 日
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!

回答 (2 件)

KSSV
KSSV 2017 年 4 月 11 日
You can read the data from each file and combine them:
t = [A ; B ; C; D] ;

Peter Perkins
Peter Perkins 2017 年 4 月 12 日
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.

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by