Reputation: 1527
Hello I have a char matrix that represents a binary numbers. For example:
0000
1010
0111
.
.
.
1010
How can I convert it to a logical matrix?
Upvotes: 1
Views: 421
Reputation: 9864
You can compare it with character '1'
>> A=['0101';'1011']
A =
0101
1011
>> A=='1'
ans =
0 1 0 1
1 0 1 1
Upvotes: 4
Reputation: 4136
Is this what you want?
a = {'0000'; '1010'; '0111'};
b = logical(double(cell2mat(a)) - 48);
gives,
>> b
b =
0 0 0 0
1 0 1 0
0 1 1 1
>> class(b)
ans =
logical
Upvotes: 1