MATLAB: Get the max value and the indices of max value across a series of matrices

cellindexmatricesmatrixmax

I have a 25×50 matrix each having another 128×128 matrix in each cell. Now I want to create a 25×1 matrix that will have a 128×128 matrix in each cell containing the maximum value across those eleven 128×128 matrices in each row. I also need the index of that cell from which the maximum value came from.

Best Answer

Let A - your cell array (25 x 50) with double matrix 128 x 128.
n = size(A,1);
maxvalue = cell(n,1);
maxidx = cell(n,1);
for ii = 1:n
[maxvalue{ii},maxidx{ii}] = max(cat(3,A{ii,:}),[],3);
end