Convert cell to matrix
3 views (last 30 days)
Show older comments
Hello, i have 1x3 cell
'00000000' '00000010' '00000011'
how do i convert it into matrix form to be like this?
0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 1
Thank you
0 Comments
Accepted Answer
Jan
on 16 Oct 2022
Edited: Jan
on 16 Oct 2022
C = {'00000000', '00000010', '00000011'};
D = cat(1, C{:}); % Convert to matrix of type CHAR
E = D - '0' % Convert to double matrix
Subtracting CHAR values from each other converts them do their ASCII values:
double('01')
double('1') - double('0') is treated exactly as '1' - '0'.
More Answers (1)
Walter Roberson
on 16 Oct 2022
Edited: Walter Roberson
on 16 Oct 2022
C = {'00000000', '00000010', '00000011'};
E = char(C) - '0'
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!