Ok, I have data spanning numerous years, and part of my analysis requires me to know the Monday that precedes the third Friday of every month. Right now I am stuck on just calculating the third Friday of the month.
tdayStr=datestr(datenum(num2str(vifDate),'yyyymmdd')); % turn vifDate into string
dt=datetime(tdayStr); % get datetime format to extrapolate day of week
m=month(dt); % get month of each date
y=year(dt); % get year of each date
dayNumber=day(dt,'dayofweek'); % Friday=6
x=zeros(81,1); % preallocate a vector and find the Fridays of each month/year
yUnique=unique(y);mUnique=unique(m);for i = yUnique(1:end); for j = mUnique(1,end); f=find(j==mUnique & dayNumber==6); %x(i)=f(3);
endend
The code breaks down at "f=find(j==mUnique & dayNumber==6);", and the error says inputs must have the same size. How can I troubleshoot this error, and more importantly, after finding the third Friday of every month, how can I get the preceding Monday?
Thank you for reading.
Best Answer