Removing weekends and holidays from a TimeTable

조회 수: 9 (최근 30일)
Andy
Andy 2018년 3월 14일
댓글: Peter Perkins 2021년 2월 18일
How can one remove weekends and holidays entries from a TimeTable?
Thanks!

채택된 답변

Peter Perkins
Peter Perkins 2018년 3월 15일
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
ismember(dateshift(TT.Time,'start','day'),listOfHolidays)
Also, if you have access to the Financial Toolbox, you can use that to generate a list of dates to remove.
  댓글 수: 4
Wolfgang McCormack
Wolfgang McCormack 2021년 1월 19일
@Peter Perkins hi, how can i get the reverse of what you just did with weekends, How can I get rid of weekdays and keep the wekend only?
Peter Perkins
Peter Perkins 2021년 2월 18일
Leave out the ~.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sonima
Sonima 2019년 4월 20일
편집: Sonima 2019년 4월 20일
Hi!
This works and remove the weekends from a TimeTable, but still gaps showed up on the plot!
TT = TT(~isweekend(TT.Time),:);
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 4월 24일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by