can anyone suggest me how to convert binary value to gray code value??

53 visualizaciones (últimos 30 días)
Rezaur Rahman
Rezaur Rahman el 29 de Abr. de 2016
Comentada: Image Analyst el 29 de Abr. de 2016
i would also like to know if you can provide me with the reverse conversion code of gray to binary value...thank you in advance.. :)

Respuestas (2)

Guillaume
Guillaume el 29 de Abr. de 2016
The wikipedia article gives a very simple algorithm. I'm not sure what the difficulty is in converting it to matlab:
function num = GrayToBinary(num)
mask = bitshift(num, -1);
while mask > 0
num = bitxor(num, mask);
mask = bitshift(mask, -1);
end
end

Image Analyst
Image Analyst el 29 de Abr. de 2016
In the Communications Systems Toolbox:
bin2gray
Convert positive integers into corresponding Gray-encoded integers
Syntax y = bin2gray(x,modulation,M) [y,map] = bin2gray(x,modulation,M)
Description y = bin2gray(x,modulation,M) generates a Gray-encoded vector or matrix output y with the same dimensions as its input parameter x. x can be a scalar, vector, or matrix. modulation is the modulation type and must be a string equal to 'qam', 'pam', 'fsk', 'dpsk', or 'psk'. M is the modulation order that can be an integer power of 2.
  2 comentarios
Rezaur Rahman
Rezaur Rahman el 29 de Abr. de 2016
please do give the code...it will be a great help for me...and i dnt understand why the modulation is needed for the conversion...anyways, thanx... :)
Image Analyst
Image Analyst el 29 de Abr. de 2016
I don't have that toolbox. If you do, then in the help there is nearly always example code. You can ask for a trial version for a month if you want. It's free for a month. Good luck.

Iniciar sesión para comentar.

Categorías

Más información sobre PHY Components en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by