MATLAB: Minimum of different sized cell arrays using cell2mat error

cell arrays

How do i find the overall minimum of a cell array, cell2mat gives error.
Y= {[100 200] [50 100] [20] [30 140];
[10 130] [40] [60 200] [30]};
min(cell2mat(Y))
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 78)
m = cat(1,m{:});

Best Answer

cell2mat fails because not all cells of Y are the same size. But you do not need this step to find the minimum:
Y= {[100 200] [50 100] [20] [30 140];
[10 130] [40] [60 200] [30]};
minC = cellfun(@(c) min([c(:) ; Inf]), Y) % get the minimum of each cell, added Inf to deal with empty cells
minY = min(minC(:)) % get the global minimum