4.33333

4.3 | 12 ratings Rate this file 34 Downloads (last 30 days) File Size: 1.1 KB File ID: #6879

Fast Walsh-Hadamard Transform

by Gylson Thomas

 

08 Feb 2005 (Updated 14 Nov 2007)

The function implement the sequency(Walsh) ordered fast Walsh-Hadamard transform.

| Watch this File

File Information
Description

The function implement the 1D sequency(Walsh) ordered fast Walsh-Hadamard transform which can be used in signal processing, pattern recongnition and Genetic alogorithms.
This algorithm uses a Cooley-Tukey type signal flow graph and is implemented in N log2 N additions and subtractions. Data sequence length must be an integer power of 2.
The inverse transform is the same as the forward transform except for the multiplication factor N. This can be easily achieved by deleting the last line i.e. x=inv(N)*x;
Example:
x=[1 2 1 1];
W=FWHT(x);

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Walsh Transform(1D)

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (15)
18 Apr 2005 Larry Kenney

Excellent compact implementation

11 May 2005 Jiang Anyou

Hello,
      How can know the full detail of the algorithm of Fast Walsh Hadamard transformation?

16 Jun 2005 fras hafeid

how to get fwht from wht?

19 Jul 2005 jeissonjavier rey duque  
29 Mar 2006 Baojun Qi

Very good!

03 Aug 2006 sin r

i'm interested to know more bout the natural ordered hadamard transforms. could u give us more info?

03 Jul 2007 f f  
01 Aug 2007 Nedunuri krishna  
02 Sep 2007 Laszlo Hars

The Hadamard transform is useful outside of signal processing, too, so it is unfortunate that this nice little function requires the Signal Processing Toolbox. However, the need is only a three-line function:
function R = bitrevorder(X)
% rearrange vector X to reverse bit order, upto max 2^k size <= length(X)
[f,e] = log2(length(X));
I = dec2bin(0:pow2(0.5,e)-1);
R = X(bin2dec(I(:,e-1:-1:1))+1);

If you save it under the filename bitrevorder.m, FWHT works without the signal processing toolbox. If you change the first few lines of FWHT to
x = bitrevorder(data);
N = length(x);
k1 = N; k2 = 1; k3 = N/2;
for i1=1:log2(N) %Iteration stage …

the input data vector will be truncated to the largest power of two size, not exceeding the length of data, so you need not worry about odd lengths.

11 Dec 2007 Jaseem Mohamed  
09 Jun 2008 Ranga Dias  
10 Jun 2008 Mayra V  
25 Aug 2008 Sumit Jha007

The code was good but the file name & function command name has to be same.

27 Aug 2008 Saifuldeen A-Mohammed  
11 Aug 2009 Stephen Becker

As of R2008b, Matlab's Signal Processing toolbox has the functions "fwht" and "ifwht" for the Fast Walsh-Hadamard (aka Hadamard) Transform, and you can choose among three different orderings. This builtin code doesn't work on very large vectors though, whereas I know it is possible to operate on these large vectors because a friend gave me some mex code that does just that. I haven't compared with the file posted here.

Please login to add a comment or rating.
Updates
16 Mar 2005

sequency ordered Walsh transform is the most common in use similar to FFT.

17 Mar 2005

A correction in example and reference is added

11 Apr 2005

Shorcut for determining Inverse FWHT

14 Nov 2007

As per the 9th review comment, in order to avoid signal processing toolbox, the bitrevorder function is also incorporated along with the main source code.

Tag Activity for this File
Tag Applied By Date/Time
transforms Gylson Thomas 22 Oct 2008 07:40:53
walsh transform Gylson Thomas 22 Oct 2008 07:40:53
fast Gylson Thomas 22 Oct 2008 07:40:53
hadamard Gylson Thomas 22 Oct 2008 07:40:53
1d Gylson Thomas 22 Oct 2008 07:40:53
sequency Gylson Thomas 22 Oct 2008 07:40:53
1d Sahar Mirzaei 22 Dec 2008 06:58:19
hadamard Thomas 17 Mar 2009 17:02:02
fast Mriganka Gogoi 26 Apr 2011 16:58:09
transforms Mriganka Gogoi 11 May 2011 16:21:48

Contact us at files@mathworks.com