Create timeseries from timeseries
조회 수: 3 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!