MATLAB Answers

Removing weekends and holidays from a TimeTable

40 views (last 30 days)
Andy on 14 Mar 2018
Commented: Peter Perkins on 18 Feb 2021
How can one remove weekends and holidays entries from a TimeTable?

Accepted Answer

Peter Perkins
Peter Perkins on 15 Mar 2018
Weekends is simple:
TT = TT(~isweekend(TT.Time),:) % assumes the default name, Time, for the row times
Holidays are another story, but if you have a list of the ones you care about, use ismember on TT.Time. You may need to use dateshift to "round" to whole days, depending on what your data look like. Perhaps something like
Also, if you have access to the Financial Toolbox, you can use that to generate a list of dates to remove.

Sign in to comment.

More Answers (1)

Sonima on 20 Apr 2019
Edited: Sonima on 20 Apr 2019
This works and remove the weekends from a TimeTable, but still gaps showed up on the plot!
TT = TT(~isweekend(TT.Time),:);
  1 Comment
Walter Roberson
Walter Roberson on 24 Apr 2019
Yes, this is to be expected. plot() positions elements by relative numeric position, and the relative numeric position of Monday to Monday is 7 days not 5 days.
You could look in the File Exchange for the various "break plot" routines. Or... you could use a time axes that was some kind of relative business days apart measure and adjust the tick labels to the associated dates.
Either way, getting zoom and pan and data tips (datacursor) right is a nuisance

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!