How to synchronize multiple timeseries

조회 수: 21 (최근 30일)
David Doria
David Doria 2013년 5월 7일
댓글: Steven Lord 2019년 8월 27일
The synchronize() function only takes 2 timeseries arguments. What is the standard procedure if you need to sync more than 2 timeseries? I tried to sync (one of the outputs of syncing timeseries 1 and 2) with timeseries 3, but the results are not synced (e.g. the same length) (as shown below) because it simply has to do with the range of the time data:
% Create data set 1
t1 = rand(10,1);
data1=rand(10,1);
ts1=timeseries(data1,t1);
% Create data set 2
t2 = rand(8,1);
data2=rand(length(t2), 1);
ts2=timeseries(data2,t2);
% Create data set 3
t3 = rand(5,1);
data3=rand(length(t3), 1);
ts3=timeseries(data3,t3);
% Sync 1 and 2
[uniform_ts12_1 uniform_ts12_2] = synchronize(ts1,ts2,'Uniform','Interval',.1);
% Sync 3 to one of the results of the (sync of 1 and 2)
[uniform_ts13_1 uniform_ts13_3] = synchronize(uniform_ts12_1,ts3,'Uniform','Interval',.1);
disp('New sizes:')
length(uniform_ts12_1.Data)
length(uniform_ts12_2.Data)
length(uniform_ts13_1.Data)
length(uniform_ts13_3.Data)
The problem is that the lengths of uniform_ts12_1, uniform_ts12_2, uniform_ts13_1, and length(uniform_ts13 are not the same. It syncs 2 with 1, but then if 3 is outside (or well inside) the bounds of 2, it syncs them to the smaller one (3), which is now not the same length as the sync between 1 and 2.
Can anyone suggest how to sync 3 timeseries so they all have identical time data at the end of the day?
Thanks,
David
  댓글 수: 1
Sebastian
Sebastian 2013년 11월 8일
This is of importance to me as well

댓글을 달려면 로그인하십시오.

답변 (1개)

Andy Campbell
Andy Campbell 2014년 5월 17일
  댓글 수: 2
Alex
Alex 2019년 8월 27일
@Andy: Thank you. But, how about using the synchronize function for more than 3 tables (say, 100 tables). Any idea on how to achieve it?
P.S.: Sorry for hijacking the post.
Steven Lord
Steven Lord 2019년 8월 27일
You've stored your timetable arrays as elements of a cell array rather than individually numbered variables, right? The general consensus is that individually numbered variables have some significant drawbacks.
If so, use that cell array as a comma-separated list when calling synchronize (see the "Function Call Arguments" item under the "How to Use the Comma-Separated Lists" section on that documentation page.)
x = {4, 8, 15, 16, 23, 42};
y = [x{:}]

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by