No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Gray Code Manipulation

5.0 | 2 ratings Rate this file 7 Downloads (last 30 days) File Size: 7.48 KB File ID: #15570 Version: 1.0

Gray Code Manipulation



12 Jul 2007 (Updated )

Generate Gray Codes and convert them to integers.

| Watch this File

File Information

Gray Codes are used for Goniometers,
a Hamiltonian Circuit on a Hypercube,
and for searches and optimizations
of functions of a few variables each
of which takes a few discrete values.
For details see file GrayCode.txt
that is included with this submission.

MATLAB release MATLAB 5.2 (R10)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
05 Jul 2016 Dongliang Hao

Good Job!

26 Nov 2008 Richard Younger

You can get at least a 5-10x speedup in the integer routines by changing the routines to cast floats to the correct uint** type and replacing the fix(0.5*k) with bitshift(k, -1).

For the 10-12 bit long codes I'm working with, graytest(10) and (12), the ratio goes from ~ 400 to 1500/2800 upon changing the routine, including the appropriate type checking and casting.

Also, the fix() call in int2gray() at least doesn't play nicely with a uint** passed in. I haven't checked gray2int().

That said, I've gotten great use out of (my modified versions of) these routines. Thanks for providing them.

Comment only
06 Sep 2008 my name is chris

great stufff ;)

Contact us