Hi,
Below is my code. For each month of each year I am trying to get the average and std for a set of values. The first iteration works for the first year. But then it does not continue. Can someone tell me where the problem is.
[M,ia,ic] = unique(CO2_FFD(:,2)); %find unique years, M = unique year, ia = row with unique year
m=[1;2;3;4;5;6;7;8;9;10;11;12];%set an array for 12 months
CO2_YM_averages = zeros(length(M)*12,2); %array for averages & std's, size of year*12months
for i=1:length(M)
yrows = find(M(i)==CO2_FFD(:,2)); %find rows where year is equal to M(i)
for j=1:length(m)
mrows=find(CO2_FFD(yrows,3)== m(j));%find rows where month = m(i)
CO2_YM_averages(j,1) = mean(CO2_FFD(mrows,8)); %average data for each month
CO2_YM_averages(j,2) = std(CO2_FFD(mrows,8)); %std data for each month
end
end
Best Answer