Monthly average of daily time series
1 view (last 30 days)
Show older comments
I have a daily time series for 6 years. I would like to make a monthly average plot where each month is an average for all 6 years. How do I make this average?
Date are in an 2556x10 matrix with values for 2556 days x 10 stations. I have reordered the data in a 2556x3x10 matrix with year, month and value for 2556 days and 10 stations.
I have tried the following but this gives nanvalues even though I use NaN-mean mP = zeros(12,1); %preallocation F = zeros(1); %preallocation for m = 1:12; % monthly loop F = nanmean(B(find(B(:,2)==m))); % make monthly average mP(m) = F; end
I have also tried something like [unMonth,IDX] = unique(C(:,1:2),'rows');
Out = [unMonth zeros(size(unMonth,1),1)]; % Averaging for d = 1:size(unMonth,1) Out(d,end) = nanmean(C(IDX == d,end)); end
0 Comments
Answers (0)
See Also
Categories
Find more on Financial Toolbox 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!