if in a row i am having 6 numerical values of large number i want convert into binary form of length 10 bits

1 回表示 (過去 30 日間)
in a row for example 4351 890 2312 9045 234 50 i want to convert into binary form with length of 10 bits, generally i can use dec2bin code but getting for one numerical value i want to get to all six numerical

採用された回答

Stephen23
Stephen23 2018 年 12 月 30 日
>> V = [234,567,123,456,900,190];
>> M = dec2bin(V(:),10)
M =
0011101010
1000110111
0001111011
0111001000
1110000100
0010111110
Each row represents one of the input numbers.
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 12 月 30 日
Note the result will be a char array. Those 0 and 1 that show up are '0' and '1' not numeric 0 and 1. Using '0' and '1' is fine for a number of purposes, but using numeric 0 and 1 is more versatile.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 12 月 28 日
reshape((dec2bin(theVector,10)-'0').', 1, [])
  3 件のコメント
rajesh kumar
rajesh kumar 2018 年 12 月 30 日
my question is how to convert into bianry form and how to store in avariable
Walter Roberson
Walter Roberson 2018 年 12 月 30 日
The code I gave converts them values to binary with length 10 bits, and puts the result all in one vector, which is what people usually want to do when they convert a vector of numbers.

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

カテゴリ

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

タグ

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by