Divide timetable into 1s windows

3 ビュー (過去 30 日間)
Shamus Sim
Shamus Sim 2020 年 8 月 12 日
コメント済み: Steven Lord 2020 年 8 月 13 日
I have a timetable (as attached: TT.mat) and would like to divide my data into 1s windows, where all the data from 0-0.99s is put into a new timetable. Data from 1-1.99s is placed in another timetable and so forth

回答 (1 件)

Steven Lord
Steven Lord 2020 年 8 月 12 日
Rather than creating a whole bunch of small timetable arrays, could you instead use a timerange to select the appropriate subset of the rows of the timetable each time you need one of those "new" timetable arrays?
Or depending on what you want to do with the new arrays, perhaps some combination of retime, rowfun, and/or the various data preprocessing functions that accept timetable arrays (functions like groupsummary, movmean, etc.) would let you perform your operations on the various sections all at once.
  2 件のコメント
Shamus Sim
Shamus Sim 2020 年 8 月 13 日
%divide into 1s windows
for i=1:600
S(i)= timerange(seconds(i-1),seconds(i),'closed')
end
I tried this. The error I get is this.
Array formation and parentheses-style indexing with objects of class 'timerange' is not allowed. Use
objects of class 'timerange' only as scalars or use a cell array.
I have also explored retime, groupsummary. But I dont think it works because Im tryng to find the peak2peak period in my data for each 1 s window instead.
%find period
period=locs(2:end) - locs(1:end-1)
Steven Lord
Steven Lord 2020 年 8 月 13 日
Something like this?
peakPeriods = zeros(1, 600);
for p = 1:600
T = timerange(seconds(p-1), seconds(p), 'closed');
thisSecond = myTimetable(T, :);
% work on thisSecond
peakPeriods(p) = ... % or if peakPeriods is a matrix use (:, p) or (p, :)
end

サインインしてコメントする。

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by