Now I get a 5-d matrix which M[j][i][l][ref][0]…
In this matrix, j,i belong to 0~4, while l=0. ref can vary from 0 to 4.
I just want to count the number according to ref’s value.
For example,
- if ref =0, I will do count0++,
- if ref =1, count1++,
- if ref =2, count2++
- …
So, I do not care what is the value of M, I just want to know the appearing frequency with different ref value.
Thanks.
You’re not quite clear on how what you want to do depends on the actual contents of M — I’m guessing this contains some sort of variable count you want to add to your individual counts?
In this case, how about something like this:
(I have replaced your individual “count” variables with an array, which makes things much easier.)
Edit: I just saw that you don’t care what the contents of M are. In that case, I don’t really understand what you’re trying to do. Since the dimensions are constant, the number of entries that exist for a certain value of
refare always constant, and are always the same for allref— in this case, 5*5=25, since you have five entries along each of the j and i dimensions.If this is not what you want, please clarify.