I am half way there...needed to have different rules for leap and non-leap years, but still need to figure out the rest, maybe in the morning ;)
for t=1:NHours
if (Rand8H(t)== 4 || Rand8H(t)== 8) && (DateTime_Year(t)==2008 || DateTime_Year(t)==2012) %so is a leap yearmin both random and actual time
for d=1:8784
if DateTime_DaysTime_leap_num(t)== days_num_leap(d)%So the date and time match, disregarding the year
AM_ff_rand(t)= AM_ff_years{2,Rand8H(t)}(d); %Accesses the correct year based on the random choice **Use curly brackets to get to the year in the cell then smooth brackets to get the index**
end
end
elseif (Rand8H(t)~= 4 && Rand8H(t)~= 8) && (DateTime_Year(t)~=2008 && DateTime_Year(t)~=2012) %so is not a leap year in both random and actual time
for e=1:8760
if DateTime_DaysTime_num(t)== days_num(e)%So the date and time match, disregarding the year
AM_ff_rand(t)= AM_ff_years{2,Rand8H(t)}(e); %Accesses the correct year based on the random choice **Use curly brackets to get to the year in the cell then smooth brackets to get the index**
end
end
elseif (Rand8H(t)== 4 || Rand8H(t)== 8) && (DateTime_Year(t)~=2008 && DateTime_Year(t)~=2012) %random time is a leap year but actual time is not
AM_ff_rand(t)=NaN; %For just now!!
else
AM_ff_rand(t)=NaN; %For just now!!
%Some combination of the above
end
end