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

 채택된 답변

Jan
Jan 2022년 10월 16일
편집: Jan 2022년 10월 16일

0 개 추천

C = {'00000000', '00000010', '00000011'};
D = cat(1, C{:}); % Convert to matrix of type CHAR
E = D - '0' % Convert to double matrix
E = 3×8
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1
Subtracting CHAR values from each other converts them do their ASCII values:
double('01')
ans = 1×2
48 49
double('1') - double('0') is treated exactly as '1' - '0'.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 10월 16일
편집: Walter Roberson 2022년 10월 16일

0 개 추천

C = {'00000000', '00000010', '00000011'};
E = char(C) - '0'
E = 3×8
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1

카테고리

도움말 센터File Exchange에서 Psychology에 대해 자세히 알아보기

제품

태그

질문:

2022년 10월 16일

댓글:

2022년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by