What is gray coding?

6 次查看(过去 30 天)
Cantor Set
Cantor Set 2020-3-10
In the genetic toolbox of matlab, there is a function which is called bs2rv which takes random binary strings and map them to real numbers using either binary or gray coding.
I don't understand how bs2rv works, what exactly happens. I want to understand the algorithm of it, can someone help me understand it?
__________________________________________________________________________________________________
Purpose
binary string to real value conversion
Synopsis
Phen = bs2rv(Chrom, FieldD)
Description
Chrom=crtbp(Nind,Nvar) where crtbp generates a random matrix of element zero and one of size Nind rows and Nvar columns
Phen = bs2rv(Chrom, FieldD) decodes the binary representation of the
population, Chrom, into vectors of reals. The chromosomes are seen as
concatenated binary strings of given length, and decoded into real numbers over a
specified interval using either standard binary or Gray coding according to the
decoding matrix, FieldD. The resulting matrix, Phen, contains the
corresponding population phenotypes.
___________________________________________________________________
The matrix FieldD has the following structure:
The rows of the matrix are composed as follows:
len, a row vector containing the length of each substring in Chrom. Note that
sum(len) should equal length(Chrom).
lb and ub are row vectors containing the lower and upper bounds respectively for
each variable used.
code is a binary row vector indicating how each substring is decoded. Select
code(i) = 0 for standard binary and code(i) = 1 for Gray coding.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by