This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Hadamard matrix


H = hadamard(n)
H = hadamard(n,classname)



H = hadamard(n) returns the Hadamard Matrix of order n.

H = hadamard(n,classname) returns a matrix of class classname, which can be either 'single' or 'double'.


collapse all

Compute the 4-by-4 Hadamard matrix.

H = hadamard(4)
H = 4×4

     1     1     1     1
     1    -1     1    -1
     1     1    -1    -1
     1    -1    -1     1

Input Arguments

collapse all

Matrix order, specified as a scalar, nonnegative integer.

Example: hadamard(5)

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Matrix class, specified as either 'double' or 'single'.

Example: hadamard(5,'single')

Data Types: char


  • An n-by-n Hadamard matrix with n > 2 exists only if rem(n,4) = 0. This function handles only the cases where n, n/12, or n/20 is a power of 2.

More About

collapse all

Hadamard Matrix

Hadamard matrices are matrices of 1's and -1's whose columns are orthogonal,

H'*H = n*I

where [n n]=size(H) and I = eye(n,n).

They have applications in several different areas, including combinatorics, signal processing, and numerical analysis [1], [2].


[1] Ryser, Herbert J. Combinatorial Mathematics. Mathematical Association of America, 1963.

[2] Pratt, William K. Digital Signal Processing. New York, NY: John Wiley and Sons, 1978.

Extended Capabilities

See Also

| |

Introduced before R2006a