Converting a decimal matrix to binary in GA
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mohammed Islam Bourenane
le 3 Jan 2024
Commenté : Mohammed Islam Bourenane
le 5 Jan 2024
Hi,
I have a big problem in a multivariable function for Genetic Algorithms, I can't convert my decimal matrix to binary correctly it contains a signed and fractional numbers between -3 ,3.I need to finish the secript in 2 days Help please.
xx=-3+6*rand(10,1);
Thank You.
0 commentaires
Réponse acceptée
Walter Roberson
le 3 Jan 2024
Modifié(e) : Walter Roberson
le 3 Jan 2024
typecast() the decimal matrix to 'uint64', and then use bitget() to fetch the individual bits.
Example,
format long g
Num = -sqrt(5)
as64 = typecast(Num, 'uint64')
%checks to be sure that we are working with the same number
num2hex(Num)
dec2hex(as64)
%checks passed.
%get the bits
bits = bitget(as64, 64:-1:1)
Chances are quite high that this technically correct solution is useless to you.
I suggest that you post a small selection of numbers and the corresponding binary that you would like to see as a result.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Genetic Algorithm 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!