Effacer les filtres
Effacer les filtres

What is gray coding?

13 vues (au cours des 30 derniers jours)
Cantor Set
Cantor Set le 10 Mar 2020
Commenté : Image Analyst le 15 Mar 2020
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?
binary string to real value conversion
Phen = bs2rv(Chrom, FieldD)
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.
  1 commentaire
Image Analyst
Image Analyst le 15 Mar 2020
Did you look at the definition in Wikipedia?

Connectez-vous pour commenter.

Réponses (0)


En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by