Let M denote the set S n,q of n × n symmetric matrices with entries in GF(q) or the set H n,q 2 of n × n Hermitian matrices whose elements are in GF(q 2 ). Then M equipped with the rank distance d r is a metric space. We investigate d-codes in (M, d r ) and construct d-codes whose sizes are larger than the corresponding additive bounds. In the Hermitian case, we show the existence of an n-code of M, n even and n/2 odd, of size 3q n − q n/2 /2, and of a 2-code of size q 6 + q(q − 1)(q 4 + q 2 + 1)/2, for n = 3. In the symmetric case, if n is odd or if n and q are both even, we provide better upper bound on the size of a 2-code. In the case when n = 3 and q > 2, a 2-code of size q 4 + q 3 + 1 is exhibited. This provides the first infinite family of 2-codes of symmetric matrices whose size is larger than the largest possible additive 2-code and an answer to a question posed in [25, Section 7], see also [23, p. 176].