运行以下 matlab 代码:
% define new timeseries object, set Quality vector to zero
a=timeseries( ...
[1:6]', ...
[datenum('2010-1-1 0:00'):1/24:datenum('2010-1-1 05:59')]', ...
zeros(6,1) ...
);
% set meta data for new timeseries object
a.QualityInfo.Code = 0:1;
a.TimeInfo.Units = 'days';
a.TimeInfo.Increment = 1/24;
a.TimeInfo.Format = 'dd-mmm-yyyy HH:MM:SS';
a.TimeInfo.StartDate = datestr(0);
% extrapolate timevector and interpolate for half hours.
b=resample(a, ...
datenum('2009-12-31 21:00'):1/48:datenum('2010-1-1 05:59'), ...
'linear', ...
1 ...
)
给出输出:
Time vector characteristics
Length 18
Start date 31-Dec-2009 21:00:00
End date 01-Jan-2010 05:30:00
Data characteristics
Interpolation method linear
Size [18 1]
Data type double
Time Data Quality
---------------------------------------------------------------------------
31-Dec-2009 21:00:00 NaN 1
31-Dec-2009 21:30:00 NaN 1
31-Dec-2009 22:00:00 NaN 1
31-Dec-2009 22:30:00 NaN 1
31-Dec-2009 23:00:00 NaN 1
31-Dec-2009 23:30:00 NaN 1
01-Jan-2010 00:00:00 1 0
01-Jan-2010 00:30:00 1.5 1
01-Jan-2010 01:00:00 2 1
01-Jan-2010 01:30:00 2.5 1
01-Jan-2010 02:00:00 3 1
01-Jan-2010 02:30:00 3.5 1
01-Jan-2010 03:00:00 4 1
01-Jan-2010 03:30:00 4.5 1
01-Jan-2010 04:00:00 5 1
01-Jan-2010 04:30:00 5.5 1
01-Jan-2010 05:00:00 6 1
01-Jan-2010 05:30:00 NaN 1
虽然我希望输出:
Time vector characteristics
Length 18
Start date 31-Dec-2009 21:00:00
End date 01-Jan-2010 05:30:00
Data characteristics
Interpolation method linear
Size [18 1]
Data type double
Time Data Quality
---------------------------------------------------------------------------
31-Dec-2009 21:00:00 NaN 1
31-Dec-2009 21:30:00 NaN 1
31-Dec-2009 22:00:00 NaN 1
31-Dec-2009 22:30:00 NaN 1
31-Dec-2009 23:00:00 NaN 1
31-Dec-2009 23:30:00 NaN 1
01-Jan-2010 00:00:00 1 0
01-Jan-2010 00:30:00 1.5 1
01-Jan-2010 01:00:00 2 0
01-Jan-2010 01:30:00 2.5 1
01-Jan-2010 02:00:00 3 0
01-Jan-2010 02:30:00 3.5 1
01-Jan-2010 03:00:00 4 0
01-Jan-2010 03:30:00 4.5 1
01-Jan-2010 04:00:00 5 0
01-Jan-2010 04:30:00 5.5 1
01-Jan-2010 05:00:00 6 0
01-Jan-2010 05:30:00 NaN 1
给定输出和预期输出之间的区别在于,质量向量应仅针对插值和外插值设置为 1,而不应设置为未更改的值。
在 Matlab 文档中写道,只有已更改的观察的质量代码应由 interpolate 函数更改。如本例所示,情况并非如此。
有解决方法吗?
我的 matlab 版本是:MATLAB 版本 7.9.1.705 (R2009b) Service Pack 1