Skip to content

randh

Random Hermitian (complex symmetric) matrix.

r = randh(n)
r = randh(n, classname)

Returns an n×n complex Hermitian matrix — the diagonal is real-valued uniform [0, 1], off-diagonals are complex with both parts drawn from uniform [0, 1], and the lower triangle is the conjugate transpose of the upper. Useful as test data for Hermitian-matrix algorithms. The optional class-name selects between 'single', 'double', and 'longdouble' complex types.

randh(4) % 4×4 Hermitian (complex)
isequal(randh(3), randh(3)') % 1 (Hermitian → equals own conjugate transpose)
  • rands — Random symmetric matrix.
  • rand — Uniformly distributed random numbers in [0, 1].