How to remove leading zeros in decimal representation?

7 ビュー (過去 30 日間)
Noor Fatima
Noor Fatima 2022 年 8 月 10 日
コメント済み: Noor Fatima 2022 年 8 月 10 日
A = [23, 15, 256, 75];
B= dec2bin(A)
B =
4×9 char array
'000010111'
'000001111'
'100000000'
'001001011'
But I'm interested in output B as;
10111
1111
100000000
1001011
I want to remove leading zeros?

採用された回答

KSSV
KSSV 2022 年 8 月 10 日
A = [23, 15, 256, 75];
B= dec2bin(A)
B = 4×9 char array
'000010111' '000001111' '100000000' '001001011'
strip(string(B),'left','0')
ans = 4×1 string array
"10111" "1111" "100000000" "1001011"

その他の回答 (1 件)

Abderrahim. B
Abderrahim. B 2022 年 8 月 10 日
Hi!
Use str2num.
A = [23, 15, 256, 75];
B= dec2bin(A)
B = 4×9 char array
'000010111' '000001111' '100000000' '001001011'
B = str2num(B)
ans = 4×1
10111 1111 100000000 1001011
Hope this helps

カテゴリ

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