Array of 1 and 0 to decimal
조회 수: 4 (최근 30일)
이전 댓글 표시
How to convert array with 1's and 0's (array A) to decimal (array B)?
A = [1 0 0 1 0 0 1 1; 0 0 0 0 1 1 1 1; 1 0 1 0 1 0 1 0 ];
B = [147;15;170];
댓글 수: 0
채택된 답변
John D'Errico
2016년 4월 19일
편집: John D'Errico
2016년 4월 19일
B = bin2dec(char(A + '0'))
B =
147
15
170
댓글 수: 0
추가 답변 (1개)
Azzi Abdelmalek
2016년 4월 19일
A = [1 0 0 1 0 0 1 1; 0 0 0 0 1 1 1 1; 1 0 1 0 1 0 1 0 ];
out=A*2.^(size(A,2)-1:-1:0)'
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!