Name: Anonymous 2010-02-28 6:49
Report in, Matlab fags!
Say I have a 365 x 24 matrix (days x hours), and I wish to make a 6 x 4 (4 hours x seasons) matrix containing the corresponding mean values. I can use mean(mean(A(1:90,0:3))) 24 times, adjusting the values, but this seemed a bit unnecessary. I came up with a loop structure, but this doesn't cover all days, because 365 isn't neatly divisible by 4. Also, I don't care to much for a loop structure, since Matlab works fastest with vectorized structures.
This is my loop code:
Any tips for a better way?
Say I have a 365 x 24 matrix (days x hours), and I wish to make a 6 x 4 (4 hours x seasons) matrix containing the corresponding mean values. I can use mean(mean(A(1:90,0:3))) 24 times, adjusting the values, but this seemed a bit unnecessary. I came up with a loop structure, but this doesn't cover all days, because 365 isn't neatly divisible by 4. Also, I don't care to much for a loop structure, since Matlab works fastest with vectorized structures.
This is my loop code:
i = 1;
ii = 1;
j = 1;
jj = 1;
F = zeros(4,6);
while (i<273)
while (j<17)
F(ii,jj) = mean(mean(A(i:i+90,j:j+3)));
j = j + 3;
jj = jj + 1;
end
i = i + 90;
ii = ii + 1;
j = 1;
jj = 1;
endAny tips for a better way?