How to apply dec2bin on a string to get a single output?
2 ビュー (過去 30 日間)
古いコメントを表示
I want to convert decimal into binary .
Since my data is in string like
a = '56515219790691171413109057904011688695424810155802929973526481321309856242040'
I have tried dec2bin(a), but it gives output in different rows,
I need the following output
dec2bin(56515219790691171413109057904011688695424810155802929973526481321309856242040)
ans='111110011110010011110110001100010001101000000110101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
But I'm not getting the same output by dec2bin(a).
Furthermore, I have to convert all the rows in to binary by importing a .txt file. Any help is much appreciated.
Thanking in anticipation.
0 件のコメント
採用された回答
Arif Hoq
2022 年 3 月 8 日
編集済み: Arif Hoq
2022 年 3 月 8 日
a = '56515219790691171413109057904011688695424810155802929973526481321309856242040';
a1=cell2mat(split(a,' '));
a2=str2double(a1);
% check=dec2bin(5,6)
out=dec2bin(a2)
writematrix(out,'sampletable.txt')
7 件のコメント
Arif Hoq
2022 年 3 月 8 日
stephen, you are right. i was in a hurry while coding. i just checked the result not the coding size. Thank you very much for the hints.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!