adding zeros to a binary string

8 ビュー (過去 30 日間)
Chiara Adami
Chiara Adami 2013 年 2 月 14 日
Hello! This is my problem : i need to convert uint8 variables in binary ones but with 8 bits. Now, if the binary number does not have 8 bit, how can i add zero on the left, without changing the number? Does exist a MAtlab Function for this?
example
uint8 = 62
binary = dec2bin(62)
binary = 111110 -> 6 bit
instead i want 8 bit, so something like 00111110
  2 件のコメント
Jan
Jan 2013 年 2 月 14 日
When you have problems with a command, here dec2bin, reading the documentation is a good idea:
help dec2bin
doc dec2bin
Chiara Adami
Chiara Adami 2013 年 2 月 15 日
i've solved the problem on my own, reading the dec2bin dpcumentation more carefully, sorry for the stupid question :D thank you!! ^^

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

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 2 月 14 日
編集済み: Andrei Bobrov 2013 年 2 月 14 日
binary = dec2bin(62, 8)
  1 件のコメント
Chiara Adami
Chiara Adami 2013 年 2 月 15 日
you are right! I've already solved the problem on my own, reading more carefully the documentation about dec2bin function :D thank u

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

カテゴリ

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