If A is a cell array which consists 100 50x50 matrix, and i want to count a specific element N from each column of each matrix in that cell array then how can I do it in matlab?
For the general case, @Shai's answer is the way to go. However, since in this case all the matrices have the same size, you could save time by storing them in a 3D array instead of a cell array. That is, define array A
of size 50x50x100, such that A(:,:,1)
is the first matrix, A(:,:,2)
is the second and so on. Then
count = squeeze(sum(A==N)).';
where count(3,5)
is interpreted as in @Shai's answer.