Borrar filtros
Borrar filtros

Hello, everyone, i have the following problem

1 visualización (últimos 30 días)
Sascha  Winter
Sascha Winter el 6 de Oct. de 2016
Comentada: Sascha Winter el 7 de Oct. de 2016
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

Respuesta aceptada

Marc Jakobi
Marc Jakobi el 6 de Oct. de 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 comentario
Sascha  Winter
Sascha Winter el 7 de Oct. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Calendar en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by