Array of 1 and 0 to decimal
6 次查看(过去 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 个评论
采纳的回答
更多回答(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!