【问题标题】:Synchronize multiple timeseries同步多个时间序列
【发布时间】:2014-05-17 11:14:38
【问题描述】:

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 之间的同步长度不同。

【问题讨论】:

  • 你目前的方法在什么方面失败了?
  • uniform_ts12_1、uniform_ts12_2、uniform_ts13_1 和 length(uniform_ts13) 的长度不一样。它将 2 与 1 同步,但如果 3 在 2 的边界之外(或恰好在其中),它会同步它们到较小的 (3),现在与 1 和 2 之间的同步长度不同。

标签: matlab time-series


【解决方案1】:

您需要将所有可能的配对同步在一起,每次都使用同步的时间序列。我认为如果你继续修改你正在同步的时间序列,这会简化,这样你就不必跟踪要传入的值。只需保留 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

>> 

希望有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-08
    • 2016-04-18
    • 2021-02-22
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 2021-08-18
    • 1970-01-01
    相关资源
    最近更新 更多