Accelerating the pace of engineering and science

# Documentation Center

• Trial Software
• Product Updates

# fwht

Fast Walsh–Hadamard transform

## Syntax

y = fwht(x)
y = fwht(x,n)
y = fwht(x,n,ordering)

## Description

y = fwht(x) returns the coefficients of the discrete Walsh–Hadamard transform of the input x. If x is a matrix, the FWHT is calculated on each column of x. The FWHT operates only on signals with length equal to a power of 2. If the length of x is less than a power of 2, its length is padded with zeros to the next greater power of two before processing.

y = fwht(x,n) returns the n-point discrete Walsh–Hadamard transform, where n must be a power of 2. x and n must be the same length. If x is longer than n, x is truncated; if x is shorter than n, x is padded with zeros.

y = fwht(x,n,ordering) specifies the ordering to use for the returned Walsh–Hadamard transform coefficients. To specify ordering, you must enter a value for the length n or, to use the default behavior, specify an empty vector [] for n. Valid values for ordering are the following strings:

OrderingDescription
'sequency'Coefficients in order of increasing sequency value, where each row has an additional zero crossing. This is the default ordering.
'hadamard'Coefficients in normal Hadamard order.
'dyadic'Coefficients in Gray code order, where a single bit change occurs from one coefficient to the next.

For more information on the Walsh functions and ordering, see Walsh–Hadamard Transform.

## Examples

This example shows a simple input signal and the resulting transformed signal.

```x = [19 -1 11 -9 -7 13 -15 5];
y = fwht(x);
```

y contains nonzero values at these locations: 0, 1, 3, and 6. By forming the Walsh functions with the sequency values of 0, 1, 3, and 6, we can recreate x, as follows.

```w0 = [1 1 1 1 1 1 1 1];
w1 = [1 1 1 1 -1 -1 -1 -1];
w3 = [1 1 -1 -1 1 1 -1 -1];
w6 = [1 -1 1 -1 -1 1 -1 1];
w = 2*w0 + 3*w1 + 4*w3 + 10*w6;
y1=fwht(w);
x1 = ifwht(y);
```

## More About

expand all

### Algorithms

The fast Walsh-Hadamard tranform algorithm is similar to the Cooley-Tukey algorithm used for the FFT. Both use a butterfly structure to determine the transform coefficients. See the references for details.

## References

[1] Beauchamp, K.G., Applications of Walsh and Related Functions, Academic Press, 1984.

[2] Beer, T., Walsh Transforms, American Journal of Physics, Volume 49, Issue 5, May 1981.

## See Also

Was this topic helpful?