Faster way to resample a timeseries?

18 ビュー (過去 30 日間)
JR223
JR223 2019 年 10 月 22 日
回答済み: Steven Lord 2019 年 10 月 22 日
Hello,
I have about one month worth of data in a 1 minute timescale and I have a series of events which I need to resample onto that timescale.
for m=1:length(UniqueEvents)
EventLogical=strcmp(Log.Event, UniqueEvents{m});
%create a time series object for each event
EventSeries=timeseries(EventLogical, datestr(LogBook.EventStartTime));
TimeSeries=resample(EventSeries, datestr(DateTable.TimeStamp), 'zoh');
if m==1
%convert time series into cell array
TableSize=size(getabstime(TimeSeries));
StatusTable=table(zeros(TableSize(1),1));
StatusTable.TimeStamp=datetime(getabstime(TimeSeries));
VarName=strcat('Status_',Var{k});
StatusTable.Var1=[];
end
StatusTable.(VarName)(logical(TimeSeries.Data))=UniqueEvents(m);
end
Using the profiler the vast majority of runtime is a result of the resampling line
TimeSeries=resample(EventSeries, datestr(DateTable.TimeStamp), 'zoh');
Does anyone have any ideas on how to make this faster?

採用された回答

Steven Lord
Steven Lord 2019 年 10 月 22 日
If you're using a release where timetable is available, I recommend storing your data in a timetable and using the retime function.

その他の回答 (0 件)

カテゴリ

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