Link data through timestamps

2 次查看(过去 30 天)
loes visser
loes visser 2015-12-18
编辑: loes visser 2015-12-18
Hi!
I loaded monitoringsdata in matlab as arrays.
As an example;
A B
[1-1-2015 0:00 20.0] [1-1-2015 0:01 154]
[1-1-2015 0:10 22.0] [1-1-2015 0:25 258]
[1-1-2015 0:20 10.0] [1-1-2015 0:33 598]
[1-1-2015 0:30 20.3] [1-1-2015 0:45 458]
[1-1-2015 0:40 14.7] [1-1-2015 0:58 987]
[1-1-2015 0:50 18.6]
[1-1-2015 1:00 13.9]
I want to plot(A,B) (or the other way around).
I want MATLAB to search for corresponding timestamps and link the data.
Most of the data is collected with an interval of 10min, but some data is random collected in time or with an interval of 1 min.
So not all arrays have the same lenght.
For example, I want 1-1-2015 0:40 to correspond with a datapoint (or the avarage of points) between 1-1-2015 0:35 and 1-1-2015 0:44.
Is it possible to do this with MATLAB? If yes, how?
I couldn't find much usefull material on the internet.
Thank you!
  1 个评论
Jan
Jan 2015-12-18
The type and size of A and B and their elements is not clear. Perhaps you mean a string like: '1-1-2015 0:00 20.0', or a cell string like {'1-1-2015 0:00', '20.0'} or a mixed cell like {'1-1-2015 0:00', 20.0} or whatever. Please post the data in a format, which recreates it, when the readers insert it in the command window by copy&paste.

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2015-12-18
Convert the dates and times to Matlab's datenum format. Then find the corresponding bins using histcounts.
Explicite code can be posted, if you specify the data format uniquely.
  1 个评论
loes visser
loes visser 2015-12-18
编辑:loes visser 2015-12-18
Thank you!
I converted the dates with datenum myself, but I cant figure out how histcounts works.
a=2;
Tab1 = P(1).week2{1};
Tab1_DateTime = datenum({Tab1{2:end,1}},'mm/dd/yyyy HH:MM:SS AM'); % 11/9/2011 21:05:00 AM
tab1_column2 = [Tab1{2:end,a+1}];
tab1_column3 = [Tab1{2:end,a+2}];
tab1_column4 = [Tab1{2:end,a+3}];
Tab2 = P(1).week2{2};
Tab2_DateTime = datenum({Tab2{2:end,1}},'mm/dd/yyyy HH:MM:SS AM'); % 11/9/2011 12:05:00 AM
tab2_column2 = [Tab2{2:end,a+1}];
tab2_column3 = [Tab2{2:end,a+2}];
tab2_column4 = [Tab2{2:end,a+3}];
tab2_column5 = [Tab2{2:end,a+4}];
tab2_column6 = [Tab2{2:end,a+5}];
The data is al converted into P, with multiple weeks and multiple persons.
First I make a variable per tab of the excel file, in addition I make an array of each colomn seperatly.
The dimensions of most of the arrays are 1008x1 (double).
I want for example to plot(tab1_column3,tab2_column4)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by