Effacer les filtres
Effacer les filtres

converting a binary string into double using commas for separation

2 vues (au cours des 30 derniers jours)
Maria Imdad
Maria Imdad le 9 Sep 2021
Commenté : Maria Imdad le 9 Sep 2021
Hi Everyone,
I have one excel file, which has binary data and when i extract this data in matlab i get this as string i.e.
k='00101101011010101101101111101110111100000001010000110010011000101111000101001010';
now i want to convert it into
k=[0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0];
So that the values remain the same but i can convert it into a double like i mentioned above. Your help will be highly appretiated

Réponse acceptée

Dave B
Dave B le 9 Sep 2021
How about something like this?
k='00101101011010101101101111101110111100000001010000110010011000101111000101001010'
k = '00101101011010101101101111101110111100000001010000110010011000101111000101001010'
str2double(num2cell(k))
ans = 1×80
0 0 1 0 1 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 1 0 1 1 1 1 1 0 1 1

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by