The following example code can be used to calculate the correlation between a data set:
clear allFieldName = {'loc1','loc2','loc3','loc4'};data = rand(8760,4);R = corrcoef(data,'rows','pairwise');R_Values= [FieldName(nchoosek(1:size(R,1),2)) num2cell(nonzeros(tril(R,-1)))];
Here, 8760 refers to one year worth of data, where a measurement is taken every hour. I'm trying to alter this code to calculate the correlation for every month of the year so that I am left with 12 correlation values for each pair vectors. What would be the best way of doing this?
Best Answer