I would like to assign different values to a variable (SRF) which is used in a loop which is running over time (at hourly interval). Currently there is a matrix of SRF values in a matrix (41,3). I want to extract the list of values (all 41) depending upon the year (1:3). In a later loop I pull out each value from the list, but first I need to set the list using the year. I have already extracted the min and max indices (relating to the time) of each year in a variable:
year_no_idx =
1 3816
3817 11832
11833 16392
I want to do this within the time loop which is already running over each hour, but I don't want to add another loop to run over the year too, as there are several other dimensions (3 more) coming later and I would rather not complicate things further. I feel like there must be a simple way to do this in a vectorised way, but I really can't find any clues to help. I can't just write three if statements as later I want to run the same code for other data, and later also for every month, so it has to be robust. Thanks for any suggestions!