MATLAB Answers

Select rows of timetable based on Month range

33 views (last 30 days)
Eric Escoto
Eric Escoto on 23 Sep 2021 at 22:51
Commented: dpb on 25 Sep 2021 at 17:55
Can someone provide the syntax for selecting monthly rowtimes from a timeteble? I would like to select various months. For example, Nov., Dec., Jan., Feb.
Here is what I'm trying:
The 'wintertime' variable and the follwing lines are also screwed up.
% Create new timetables at differing scales.
% Extract the month record
monthofTT = month(TT.Time);
% Determine which records are between November and March (months 1:3 and
% 11:12)
wintertime = [1,3;11,12]; % [start, end] of desired months
wintermonths = monthofTT >= winter(1) & wintertime <= winter(2);
% Isolate all row in winter months
TTwinter = TT(month(TT.Time(winterrmonths)), :);

Accepted Answer

dpb on 23 Sep 2021 at 23:34
Edited: dpb on 24 Sep 2021 at 11:41
To use the numeric months,
wintertime = [1:3 11:12]; % [start, end] of desired months
TTwinter = TT(ismember(month(TT.Time),wintertime), :);
dpb on 25 Sep 2021 at 17:55
Was pretty obvious when not so tired...sorry didn't catch it at first.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!