I am currently working on a project with MODIS LST data. I have 18 years worth of daily data, although not all of it is good enough quality to use.
I am needing to set up a for loop which will generate a weekly average LST value - however this value needs to be derived from first averaging within the weeks i.e. an average of week 1 for year 1, week 2 for year 1, week 3 for year 1 and then generating an overall average for week 1 - i.e. by averaging the week 1 value for year 1 with the week 1 value for year 2 all the way to year 18. Eventually I am seeking an 52 row output which has the average for week 1-52 for the 18 years of data.
Due to the quality control issues I have generated a logical called RENLSTdayQC which selects which data is appropriate to use.
This is my current code however it is averaging all week 1 individual day values in the central for loop not the individual years. Any advice would be much appreciated!
n = 0
for i = 1:18
use = and(RenLSTdayQC, RenMODISYear == i);
use2 = and(RenLSTdayQC, RenMODISWeek == j));
RenLSTWeekAverages(n,1) = nanmean(RenLSTday(use2));
RenLST18YAverage(i,1) = nanmean(RenLSTdayWeek(use));