help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elementwise boolean operations


From: Judd Storrs
Subject: Re: elementwise boolean operations
Date: Thu, 20 May 2010 15:51:35 -0400

Gray coding seems to be interesting. Here's a way to do it based on
Gray's reflection algorithm.

function m = graycode(n)
  m = false(2^n,n) ;
  m(2,n) = true ;
  for i=1:n-1
    j = n-i ;
    k = 2^i+1:2^(i+1) ;
    m(k,j) = true ;
    m(k,j+1:end) = flipdim(m(1:2^i,j+1:end),1) ;
  endfor
endfunction


reply via email to

[Prev in Thread] Current Thread [Next in Thread]