I used it for building sequency of Hadamard matrix of order N.

Something like:

function SeqOrd = GetSequency( N )

% N - [in] the order of Hadamard matrix
% SeqOrd - [out] the sequency, so that SeqOrd[i] is the sequency of row i
%
% Algorithm:
% 1. build a list of indexes 0..N-1
% 2. convert order of bits of each index
% 3. get the gray code value for each index ( that was converted)
% This gives the needed permutation with indexes range [0 .. N-1]

v = bitrevorder((0:N-1)'); % build list and reverse bit-order

SeqOrd = bitxor(v,bitshift(v,-1)); % find the gray-code