Hello, everyone, i have the following problem

2 次查看(过去 30 天)
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

采纳的回答

Marc Jakobi
Marc Jakobi 2016-10-6
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 个评论
Sascha  Winter
Sascha Winter 2016-10-7
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.

请先登录,再进行评论。

更多回答(0 个)

类别

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