nested loop will not enter second iteration
Show older comments
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
4 Comments
Image Analyst
on 1 Jul 2017
Undefined function or variable 'CO2_FFD'.
Please supply it so we can run your code.
Jennifer Walker
on 1 Jul 2017
Jennifer Walker
on 1 Jul 2017
Jennifer Walker
on 1 Jul 2017
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!