1

synchronize() 函数只需要 2 个时间序列参数。如果您需要同步超过 2 个时间序列,标准程序是什么?我尝试将(同步时间序列 1 和 2 的输出之一)与时间序列 3 同步,但结果未同步(例如相同长度)(如下所示),因为它仅与时间数据的范围有关:

% 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)

谁能建议如何同步 3 个时间序列,以便它们在一天结束时都有相同的时间数据?

编辑:

问题是 uniform_ts12_1、uniform_ts12_2、uniform_ts13_1 和 length(uniform_ts13 的长度不一样。它将 2 与 1 同步,但是如果 3 在 2 的边界之外(或正好在里面),它会将它们同步到较小的一 (3),现在与 1 和 2 之间的同步长度不同。

4

1 回答 1

4

您需要将所有可能的配对同步在一起,每次都使用同步的时间序列。我认为如果你继续修改你正在同步的时间序列,这会简化,这样你就不必跟踪要传入的值。只需保留 3 个时间序列,当它们都被修改时,你只需要置换它们都使所有时间序列对都同步在一起:

>> [ts1 ts2] = synchronize(ts1, ts2, 'Union');
>> [ts1 ts3] = synchronize(ts1, ts3, 'Union');
>> [ts2 ts3] = synchronize(ts2, ts3, 'Union');
>> all(ts1.Time == ts2.Time)

ans =

     1

>> all(ts1.Time == ts3.Time)

ans =

 1

>> 

希望有帮助!

于 2014-05-17T03:14:38.743 回答