% CELLMAX - Find the maximum value in a cell array. Does not return its index.
% Works for up to 2D cell array
%
% maxvalue = cellmax(a)

function maxvalue = cellmax(a)
    
    arraysize = size(a);
    if length(arraysize)>2
        error('cellmax only works with up to 2D cell arrays');
    end
    
    maxvalue = NaN;
    for i=1:arraysize(1)
        for j=1:arraysize(2)
            thisval = a{i,j};
            if size(thisval,2)==1
                thisval = thisval';
            end
            maxvalue = max([maxvalue thisval]);
        end
    end
    

    
