【发布时间】:2015-02-03 19:39:49
【问题描述】:
在下面的代码中,我创建了一个简单的数据序列、一个时间向量和一个时间序列。绘制它们两个我都没有问题。 (它们在同一个图上并不重要。)我无法弄清楚的是如何对时间序列的一部分进行子集化,如最后一个因错误而失败的命令所示:
>> timeseriesTest
Error using timeseries/plot (line 27)
The plot method can only be used for a single timeseries object
Error in timeseriesTest (line 14)
plot(ts(25:end));
>>
如何提取时间序列中的最后 25 个(在本例中)值?重要提示:虽然在下面的代码中不是这样,但我的时间序列有每天或每周的时间戳,我确实需要保留它。即:
NewData = ts.data
...不是一个好的答案,除非它是获取新提取时间序列的唯一方法。
t=[1:50];
d=sin(2*pi*t/20);
ts = timeseries(2*d, t);
%plot data and timeseries
plot(d);
hold on;
plot(ts);
figure();
plot(d(25:end));
hold on;
plot(ts(25:end));
【问题讨论】:
标签: matlab time-series