Code covered by the BSD License  

Highlights from
Extended (n,k)-gray code

5.0

5.0 | 2 ratings Rate this file 9 Downloads (last 30 days) File Size: 4.17 KB File ID: #23013

Extended (n,k)-gray code

by

 

18 Feb 2009 (Updated )

We extend normal gray code to conside about different range for each digit.

| Watch this File

File Information
Description

    Our basic idea is based on (n,k)-gray code which was introduced in one paper named :"Generalized Gray Codes with Applications".

       Our extention is allowing each digit ranged from different digit which is widely useful in some situations.For example, (3,2)-Gray code is (0,0), (0,1), (0,2),(1,2),(1,0),(1,1),(2,1),(2,2),(2,0). The parameter 3 is the range of each digit {0,1,2}, and 2 restricts there are 2 digits.
     Our extended gray code is working in this way. For example, if we want to generate gray code with the range of {2 3 3 4} for each digit as input parameter, our function will produce: 0000,1000,1100,0100,0200,1200,1210,0210,........ in total of 72 sequences.

        Please start from 'ControlCenter.m', we give an example there with detailed explanation.
        I also add mex programming function for fast generation, good for advance users.Pay attention, i have only tested it under linux.
       If there is any question, please let me know, I will answer you questions within one day if internet is available.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
29 Aug 2013 Marino Pagan

Good function.

It wasn't clear to me at first how to use it: the input argument needs to be a row vector, and each element specifies the range of the corresponding digit.

n-digit binary gray code:
ImprovedGenerateGrayCode( 2*ones(1,n) )

n-digit ternary gray code: ImprovedGenerateGrayCode( 3*ones(1,n) )

and so on

18 Feb 2009 Guangdi Li  
Updates
23 Mar 2009

this time I add a detailed example, thanks for you help.

26 Jan 2010

improve it by mex programming.

Contact us