convert class 'char' to class 'logical' , How?
古いコメントを表示
I have some binary bits in a string of class 'char':
b= 10001010101010101000000111110000111
I wish to covert class of 'b' from 'char' to 'logical'.
When i use str2num function, it considers all the bits as a single number and returns me
str2num(b)
ans =
1.0001e+034
Which i don't want. i want b as a logical array.
Kindly Help.
採用された回答
その他の回答 (2 件)
William Prophet
2016 年 11 月 11 日
If you want to convert the character array to a logical one, just compare the entire array character by character. So if you have '001011' and you want to return [0 0 1 0 1 1], just do
'001011' == '1'
And then every character in the array is compared to '1'.
Andreas Goser
2014 年 1 月 17 日
1 投票
Logical can only hold 0 or 1, so 10001010101010101000000111110000111 is not possible. Maybe you want binary numbers?
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!