function [r, c] = findInMatrix(n,M)
% Find all occurrences of the number n in matrix M.
% r and c are column vectors of row and column numbers such that
%   M(r(k),c(k)) is equal to n.
% If n is not found in M, r and c are empty vectors.

% find out the size of the matrix M
[ nRow, nCol] = size(M);

% initialization
r = [];
c = [];

for i=1:nRow
    for j=1:nCol
        if M(i, j) == n
            r = [r; i];
            c = [c; j];
        end
    end
end

