Create timeseries from timeseries

5 vues (au cours des 30 derniers jours)
Pankaj
Pankaj le 20 Juil 2017
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

Réponses (1)

Robert U
Robert U le 21 Juil 2017
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

Catégories

En savoir plus sur Time Series dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by