No BSD License  

Highlights from
gc2dec

5.0

5.0 | 1 rating Rate this file 8 Downloads (last 30 days) File Size: 1.32 KB File ID: #8275

gc2dec

by

 

11 Aug 2005 (Updated )

Function to convert a gray coded sequence to a decimal sequence.

| Watch this File

File Information
Description

This function converts a gray coded string to its equivalent decimal representation. It accepts rows of gray coded string and returns the equivalent decimal sequence as a column vector.

Example:

>>g = [1 0 0 1 1;0 0 0 1 1; 0 1 1 0 1];
>>gc2dec(g)

ans =

    29
     2
     9

Acknowledgements

This file inspired Genetic Algorithm To Optimise Schaffer's F6 Function.

Required Products MATLAB Compiler
MATLAB release MATLAB 6.5.1 (R13SP1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
12 Mar 2009 Jim

Here's a gray to standard translation using builtins, no explicit looping:

d=bin2dec(int2str(mod(cumsum(dec2bin(g)=='1'),2)));

11 Jul 2007 Cathy Williams

neat work!

Contact us