Consider that elements of A might occur once, others multiple times, and some not at all. Therefore we need to resort to cell arrays and then with arrayfun, you can loop over all elements of A to find the coincidences and store them in C.
C = arrayfun(@(x) find(B==x), A, 'un', 0)
Now C{k} holds the indices into B, where B equals A(k). For example, A(1) = 4 and C{1} = 1 16, i.e., B(1) and B(16) are equal to 4.