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 CenterFile Exchange에서 Time Series에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by