I have 2-D matrix having both positive and negative decimal integer I want to convert all elements of matrix to binary numbers. How can I do this?
1 次查看(过去 30 天)
显示 更早的评论
I have 2-D matrix having both positive and negative decimal numbers I want to convert all elements of matrix to binary numbers. How can I do this?
0 个评论
回答(1 个)
Image Analyst
2017-1-28
Try this:
binaryMatrix = yourMatrix > someThreshold; % such as yourMatrix > 0 or whatever number you want.
That's a binary matrix with 0's and 1's, actually false's and true's. If you want a binary like strings, use dec2bin().
另请参阅
类别
在 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!