From question, I understood that there is a dataset containing columns of latitude, longitude, year, month and temperature.
The accumarray function returns a matrix whose dimensions depend on the maximum value of “latidx” and “longidx”. For example, the element num(1,1) gives the number of occurrences of the row [1 1] in the matrix passed as input to accumarray function. As mentioned in the question, there are 6 bins which means there are 6 non-zero elements in “num” array. The indices of these non-zero elements gives the value of latitude and longitude in each bin. Now that we have the values of latitude and longitude of a bin, extract the rows corresponding to that latitude and longitude. Loop through these rows to obtain temperatures of particular month in a year.
For more understanding on accumarray function, refer to the following link:https://www.mathworks.com/matlabcentral/answers/299710-do-not-understand-accumarray-command-in-maltab