seasonal average over years
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Agnete
am 15 Dez. 2013
Beantwortet: Image Analyst
am 15 Dez. 2013
I have monthly averages of daily data for 7 years (84x1). I would like to make an May-October average for the whole period (7x1). I have tried different approaches but I am just getting more confused.
Thank you!
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 15 Dez. 2013
Try this demo:
% Make sample data
temps = randi(100, 84, 1)
% Reshape to a month by year array.
tempsByMonth = reshape(temps, 12,7)
% Extract the May - October months.
mayThroughOct = tempsByMonth(5:10,:)
% Get the means over all those extracted months.
meanMayOct = mean(mayThroughOct(:))
Of course it could be make into a more cryptic, obtuse one liner if you wanted, but I went for understandability.
If you have the Image Processing Toolbox, you have mean2() so it can be shortened to
tempsByMonth = reshape(temps, 12,7) % Reshape to a month by year array.
meanMayOct = mean2(tempsByMonth(5:10,:)) % Get the means over extracted months.
and still be fairly readable.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!