How to build a time record from several matrices?

1 visualización (últimos 30 días)
EB
EB el 11 de Abr. de 2017
Respondida: Peter Perkins el 12 de Abr. de 2017
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!

Respuestas (2)

KSSV
KSSV el 11 de Abr. de 2017
You can read the data from each file and combine them:
t = [A ; B ; C; D] ;

Peter Perkins
Peter Perkins el 12 de Abr. de 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.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by