0
votes

I have 30 matrices (1446x1124) containing values going from 0 to 99. I would like to have an output matrix, having the same size and containing in each cell the frequency of ouccrence (between 0 and 1) of one element of this matrix (for example 2) over the 30 input matrices.

1

1 Answers

0
votes

First of all make sure your matrices are stored properly. If they are all the same size I would recommend a 3 dimensional matrix. Then it should look something like this:

M = round(rand(30,1446,1124));

Now I am not sure what shape you want the output to have, but suppose you want to know the fraction of 2s it is quite simple:

mean(M(:)==2)