フィルターのクリア

How to convert sometimes negative decimal matrix to two's complement

8 ビュー (過去 30 日間)
Nick DeMarchis
Nick DeMarchis 2019 年 5 月 20 日
回答済み: vidhathri bhat 2019 年 5 月 28 日
I have a matrix that is 667648x2, full of sometimes negative decimals that range between -1 and 1. How would I convert this matrix into some output of 16 bit two's complement binary numbers? Thank you.

回答 (1 件)

vidhathri bhat
vidhathri bhat 2019 年 5 月 28 日
Hi
You can use num2bin() function to do that. Here is an example. You can check out the functions here to change the parameters as required
x = [-0.1 0.02 -0.4; 7 9 -11]
x =
-0.1000 0.0200 -0.4000
7.0000 9.0000 -11.0000
q = quantizer([16,8])
q =
DataMode = fixed
RoundMode = floor
OverflowMode = saturate
Format = [16 8]
y = num2bin(q,x)
y =
6×16 char array
'1111111111100110'
'0000011100000000'
'0000000000000101'
'0000100100000000'
'1111111110011001'
'1111010100000000'

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by