Create timeseries from timeseries

5 ビュー (過去 30 日間)
Pankaj
Pankaj 2017 年 7 月 20 日
回答済み: Robert U 2017 年 7 月 21 日
I have a quick question to ask.
I would like to create a timeseries from a timeseries object but with given data columns. (Say there are four data types saved in different columns of timeseries; I need to extract only three columns).
I know how to do it for given time instances. One way could be that, I first extract the data and then time and then make a new timeseries. I want a quick way.
Thanks

回答 (1 件)

Robert U
Robert U 2017 年 7 月 21 日
Hi Pankaj,
if I understand your question correctly, the quick way might be to utilize the methods provided by timeseries class. One possibility to reduce the number of data "columns" is shown below along with cropping the timeseries to a given start and end time:
% Create timeseries
time = 0:0.01:2;
for ik = 1:4
data(:,ik) = sin((2 * pi * 5 * time) + ((ik-1) * pi/2));
end
TS_initial = timeseries(data,time);
% Extract part of the timeseries
startTime = 0.5;
endTime = 1.5;
colsToExtract = [2 3 4];
if size(colsToExtract,1) > 0
% copy the original time series
TS_extract = TS_initial;
% select the data
TS_extract.Data = TS_extract.Data(:,colsToExtract);
% extract for a given time range
TS_extract = TS_extract.getsampleusingtime(startTime,endTime);
end
Kind regards,
Robert

カテゴリ

Help Center および File ExchangeTime Series についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by