floating point to binary conversion

7 visualizzazioni (ultimi 30 giorni)
ashok
ashok il 28 Apr 2014
Risposto: Walter Roberson il 28 Apr 2014
if true
% code
if a =
-5932.62103114252
5931.17666698258
5797.34103035393
-6358.78042353988
-12430.1210180646
-9849.27324380255
-6386.88118380371
7783.15716000243
5177.38696737792
6082.47763148202
-4816.43707738488...........
end
how to convert this to binary? with out using uint8,16,64 i need the output in double
if i use uint the values are rounded off and i am not able to reconstruct (image) is there any possibilities to convert it.
because after converting it i need to modulate and transmit.

Risposta accettata

Walter Roberson
Walter Roberson il 28 Apr 2014
dec2bin(typecast(YourFloatingPointVector, 'uint64'), 64) - '0'

Più risposte (1)

Image Analyst
Image Analyst il 28 Apr 2014
I don't know what you mean. The image already is in double. What do you mean by "binary"? You mean binary like a binary image, where the pixels are true or false and the data type is logical? You can create that by thresholding and casting to double:
binaryImage = a < 1000; % Whatever value... binaryImage is of type "logical".
doubleImage = double(binaryImage); % Make double.
What are you talking about uint8, uint16, etc. Those aren't binary except in the sense that ALL numbers in a computer are binary. Maybe you want the dec2bin() function to turns numbers into strings of 0's and 1's.

Community Treasure Hunt

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

Start Hunting!

Translated by