I have the following code (below) that uses a for loop. Why do I get the error "Subscript indices must either be real positive integers or logicals"?
data.Year=year(data.Date);data.Month=month(data.Date);data.Day=day(data.Date);data.Hour=hour(data.Date)+1;data.Wday=weekday(data.Date);data.Bday=isbusday(data.Date);data.Hday=1*((data.Bday==0)&((data.Wday~=1)&(data.Wday~=7)));data.Hday2=data.Hday;[rows, cols]=size(data.Hday);for m=1:rows if (data.Hday(m)==1)&&((data.Month(m)==12)||(data.Month(m)==11)||(data.Month(m)==9)|(data.Month(m)==7)|(data.Month(m)==5)) data.Hday2(m)=data.Hday(m)+1; data.nday(m)=0; elseif (data.Hday(m)==1)&&(data.Month(m)==1)&&(data.Day(m)<8) data.Hday2(m)=data.Hday(m)+1; data.nday(m)=0; elseif (data.Hday(m)==1) data.Hday2(m)=1; data.nday(m)=0; elseif (data.Hday(m-1)==1)&&(data.Month(m-1)==11) data.Hday2(m)=.5 else data.Hday2(m)=0; data.nday(m)=1; endend
Best Answer