Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
I have a vector that represents monthly values for 30 years of data (i.e. 360 discrete values). I need to write a programming loop that finds the maximum value in each year. I'm having an issue setting up a counter on the "max" function. Any suggestions?
Please post a worksheet with the data and what you have so far.
It's easier to do it by splitting out each year using the submatrix function.
That worked perfectly. I have never used the submatrix command, but I will now. Thanks for your help!
After looking at other datasets, I don't think the submatrix command will work. It just so happens that the dataset that I provided had the max values in January of every year. Other datasets may not have this (i.e. the max may not occur in the same month every year). It appears that the programmer sets the increments (i.e. ir, jr, ic, jc), which returns a value specified by the increments chosen, not necessarily the maximum in each year. Am I intrepreting this correctly? If so, is there another way to calculate the maximum value in every year?
The submatrix function takes the GW vector and splits out a new vector for a given year. The max function finds the maximum value in that new vector, regardless of it's position. So yes, it will work.
As Richard has indicated in his worksheet you should try and post a worksheet with the problem section only. This helps other collabs get involved and take stock of the help offered by others without spending a lot of time trawling through long sheets.
Mike