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

2 ビュー (過去 30 日間)
MEENU SAINI
MEENU SAINI 2016 年 6 月 19 日
コメント済み: Walter Roberson 2016 年 6 月 20 日
I want to convert whole file of real numbers having atleast 1000 data points into binary/hex using some function or program. Plz help

採用された回答

Walter Roberson
Walter Roberson 2016 年 6 月 19 日
num2hex() is the routine to use to see the hex representation of the IEEE 754 bit pattern for float or double.
  1 件のコメント
MEENU SAINI
MEENU SAINI 2016 年 6 月 19 日
yes num2hex() is working for files containing real numbers. Thanks a lot for your reply!!

サインインしてコメントする。

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 6 月 19 日
編集済み: Azzi Abdelmalek 2016 年 6 月 19 日
You can use dec2bin and dec2hex function
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 6 月 19 日
No, that only works for non-negative integers.

サインインしてコメントする。


MEENU SAINI
MEENU SAINI 2016 年 6 月 19 日
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 件のコメント
MEENU SAINI
MEENU SAINI 2016 年 6 月 20 日
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 2016 年 6 月 20 日
https://www.mathworks.com/matlabcentral/newsreader/view_thread/30803

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by