MATLAB: Calculating discharge over multiple years

discharge

Need a function that finds the monthly maximum discharge. It should output two values, the discharge itself and the row in which each value occurs. The code should extract results for all months in all years.
I have a data set that has discharge in first column, day, month then year in 2,3 and 4 columns.

Best Answer

Use a table or timetable and rowfun with grouping variables...a couple lines of code and an anonymous function will do it.
For the second desired output you may find augmenting the table with the row number may be the expeditious solution.