How to apply dec2bin on a string to get a single output?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Arif Hoq
le 8 Mar 2022
Modifié(e) : Arif Hoq
le 8 Mar 2022
a = '56515219790691171413109057904011688695424810155802929973526481321309856242040';
a1=cell2mat(split(a,' '));
a2=str2double(a1);
% check=dec2bin(5,6)
out=dec2bin(a2)
writematrix(out,'sampletable.txt')
7 commentaires
Arif Hoq
le 8 Mar 2022
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!