converting a binary string into double using commas for separation

조회 수: 3 (최근 30일)
Maria Imdad
Maria Imdad 2021년 9월 9일
댓글: Maria Imdad 2021년 9월 9일
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

채택된 답변

Dave B
Dave B 2021년 9월 9일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by