function val = minInMatrix(M)
% Return min value in matrix M

val = M(1,1);
[nr, nc] = size(M);

for r = 1:nr
    for c = 1:nc
        val = min(val, M(r,c));
    end
end
