How to take monthly flow data and obtain annual max flow values

2 visualizzazioni (ultimi 30 giorni)
I have a data set with months (numbered from 1 to 12) in column 1 and monthly max flows in column 2. I would like to obtain the yearly maximum flows over the entire 81 year span (972 months) of this dataset. Essentially, for every 12 months (1-12) I would like to find a maximum and then I would like to compile these 81 flows (the month of max occurrence in a year does not matter to me). Any tips on how I might go about this?
1 36000
2 218000
3 24300
4 43200
5 8430
6 2230
7 535
8 205
9 110
10 100
11 4220
12 18100
1 6680
2 53600
3 27000
4 20100
5 2030
6 680
7 150
8 80
9 120
10 144
11 4500
12 7020

Risposte (2)

Ajay Kumar
Ajay Kumar il 26 Set 2019
Modificato: Ajay Kumar il 26 Set 2019
Your data being X,
data = X(:,2);
yearly_max = zeros(length(data)/12,1);
j=1;
for i=1:length(data)/12
yearly_max(i)=max(data((j:j+11),1));
j=j+12;
end
Here, I have neglected the first column in X (your matrix), as it is of no use.
Please accept the answer, if you got what you need. Thanks :)

Akira Agata
Akira Agata il 26 Set 2019
Assuming your data was stored in 972-by-2 matrix yourData, following code can do your task.
year = repelem([1:81]',12,1);
yearlyMax = splitapply(@max,yourData(:,2),year);
By the way, if you will do some more analysis on your data, I would recommend creating datetime vector and storing your data as timetable variable.

Prodotti


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by