Filter löschen
Filter löschen

How to convert a file containing real numbers into binary/hexadecimal?

2 Ansichten (letzte 30 Tage)
I want to convert whole file of real numbers having atleast 1000 data points into binary/hex using some function or program. Plz help

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Jun. 2016
num2hex() is the routine to use to see the hex representation of the IEEE 754 bit pattern for float or double.
  1 Kommentar
MEENU SAINI
MEENU SAINI am 19 Jun. 2016
yes num2hex() is working for files containing real numbers. Thanks a lot for your reply!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 19 Jun. 2016
Bearbeitet: Azzi Abdelmalek am 19 Jun. 2016
You can use dec2bin and dec2hex function

MEENU SAINI
MEENU SAINI am 19 Jun. 2016
but there is some problem in the converted data. I have converted a file containing 1000 real numbers to hexadecimal using this function num2hex(). The real numbers are like:
-0.0128380000000000
-0.0142530000000000
-0.0080360000000000
-0.0120290000000000
-0.0136970000000000
-0.0268890000000000
-0.0320450000000000
-0.0295180000000000 & so on upto 1000.
--
The converted hex file is looking like:
bf8a4acf312b1b37
bf8d30ad46f587d7
bf80752da98676a7
bf88a2a90cd423d9
bf8c0d2c386d2ed8
bf9b88ca3e7d1351
bfa06833c60029f1
bf9e39f77292c493
--
but I think it should be like:
0xbc52567a
0xbc69856a
0xbc03a96d
0xbc451548
0xbc606962
0xbcdc4652
0xbd03419e
--
Is there any solution to this? Plz reply
  3 Kommentare
MEENU SAINI
MEENU SAINI am 20 Jun. 2016
Thank you Sir!! I have one more problem that after processing this converted data file, I need to convert this hex file back to real data file. So what function should I use? Plz help!
Walter Roberson
Walter Roberson am 20 Jun. 2016
https://www.mathworks.com/matlabcentral/newsreader/view_thread/30803

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by