converting a binary string into double using commas for separation

3 views (last 30 days)
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

Accepted Answer

Dave B
Dave B on 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

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!