Hello, everyone, i have the following problem

1 view (last 30 days)
I have two data sets. One containing of dates from 1994-2016 where the weekends are already exluded and one with some dates of meetings (176 meetings) in this time-period. Now I have to construct eight Week-Dummies (from week -1 to week 6).
For example week 0 is defined as day -1 to day +3 where day 0 is the day of the meeting. I wanted to work with the function ismember, as in the example below. My problem is that sometimes date_num + i brings me to a weekend day which is not included in the data set and therefore MATLAB values it as a zero, but I need to give a command that it jumps to the next date which is included in the data set.
%week 0
FOMC_DUMMY_w0m1 = ismember(date_num,event_date_num - 1);
FOMC_DUMMY_w00 = ismember(date_num,event_date_num);
FOMC_DUMMY_w0p1 = ismember(date_num,event_date_num + 1);
FOMC_DUMMY_w0p2 = ismember(date_num,event_date_num + 2);
FOMC_DUMMY_w0p3 = ismember(date_num,event_date_num + 3);
FOMC_DUMMY_0 = [FOMC_DUMMY_w0m1 FOMC_DUMMY_w00 FOMC_DUMMY_w0p1 FOMC_DUMMY_w0p2 FOMC_DUMMY_w0p3];
FOMC_DUMMY_w0neu = sum(FOMC_DUMMY_0,2);
I hope you get my problem and I thank you all in advance for your answers

Accepted Answer

Marc Jakobi
Marc Jakobi on 6 Oct 2016
I assume your date_num values are datenums?
How about something like:
wd = weekday(date_num + i);
if wd == 1
i = i + 1;
elseif wd == 7
i = i + 2;
end
  1 Comment
Sascha  Winter
Sascha Winter on 7 Oct 2016
First thank you for your answer, i also thought about something like this but the problem is that there are several weekdays where there was no tradin dday so these days are also not part of the data set.
I fortunately got help with a different possibility to solve the problem.

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!