MATLAB Answers

0

Convert String to binary in each element

Asked by zahrein yaacob on 13 Jul 2019
Latest activity Commented on by zahrein yaacob on 13 Jul 2019
Hi , i want to convert the string here in binary format so that i can manipulate the element of bits. I want to convert into binary for each element.
Here what i have:
kol =
10×1 string array
"1"
"0"
"1"
"1"
"1"
"1"
"0"
"1"
"1"
"1"

  0 Comments

Sign in to comment.

Tags

Products


Release

R2018a

1 Answer

Answer by KALYAN ACHARJYA on 13 Jul 2019
Edited by KALYAN ACHARJYA on 13 Jul 2019
 Accepted Answer

kol='1';
data1=str2double(kol);
data2=logical(data1)
Command Window:
>> whos data2
Name Size Bytes Class Attributes
data2 1x1 1 logical

  4 Comments

Show 1 older comment
Incorporated, Thank you @madhan ravi
Well, actually, since the input is a string array, just double will do it:
>> kol = ["0", "1", "1", "1", "1", "0", "1", "1", "1"];
>> double(kol)
ans =
0 1 1 1 1 0 1 1 1
Thanks , it works.

Sign in to comment.