function [Jmat]=graycode(k);
% PURPOSE: generates a set of 2^k unique rows of k elements set to either "0" or "1"
% 
%
% Written by:
% Klaus Moeltner
% Department of Resource Economics
% University of Nevada, Reno
% moeltner@cabnr.unr.edu

M=2^k; %Model space

j=1;
Jmat=[0;1];
for i=1:k-1
    nJ=size(Jmat,1);
    int0=zeros(nJ,1);
    int1=ones(nJ,1);
    Jmat=[[int0 Jmat];[int1 Jmat]];
end
