Hello, everyone, i have the following problem
1 次查看(过去 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
0 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!